Initial Tomahawk import.
11
.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
qtcreator-build/*
|
||||||
|
build/*
|
||||||
|
.directory
|
||||||
|
*.a
|
||||||
|
*.o
|
||||||
|
._*
|
||||||
|
*.user
|
||||||
|
Makefile*
|
||||||
|
moc_*
|
||||||
|
*~
|
||||||
|
/playdar
|
31
CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
PROJECT( tomahawk )
|
||||||
|
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
|
||||||
|
|
||||||
|
SET( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
|
||||||
|
|
||||||
|
# Check if we need qtgui:
|
||||||
|
IF( "${gui}" STREQUAL "no" )
|
||||||
|
ADD_DEFINITIONS( -DENABLE_HEADLESS )
|
||||||
|
MESSAGE( STATUS "Building in HEADLESS mode ***" )
|
||||||
|
FIND_PACKAGE( Qt4 4.6.0 COMPONENTS QtCore QtXml QtNetwork REQUIRED )
|
||||||
|
ELSE()
|
||||||
|
MESSAGE( STATUS "Building full GUI version ***" )
|
||||||
|
FIND_PACKAGE( Qt4 4.6.0 COMPONENTS QtGui QtCore QtXml QtNetwork REQUIRED )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
FIND_PACKAGE( Taglib 1.6.0 REQUIRED )
|
||||||
|
FIND_PACKAGE( LibLastFm REQUIRED )
|
||||||
|
|
||||||
|
IF( "${gui}" STREQUAL "no" )
|
||||||
|
ELSE()
|
||||||
|
IF( UNIX AND NOT APPLE )
|
||||||
|
ADD_SUBDIRECTORY( alsa-playback )
|
||||||
|
ELSE()
|
||||||
|
ADD_SUBDIRECTORY( rtaudio )
|
||||||
|
ENDIF( UNIX AND NOT APPLE )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
ADD_SUBDIRECTORY( libportfwd )
|
||||||
|
ADD_SUBDIRECTORY( qxtweb-standalone )
|
||||||
|
ADD_SUBDIRECTORY( src )
|
||||||
|
|
42
CMakeModules/FindLibLastFm.cmake
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# - Find LibLastFM
|
||||||
|
# Find the liblastfm includes and the liblastfm libraries
|
||||||
|
# This module defines
|
||||||
|
# LIBLASTFM_INCLUDE_DIR, root lastfm include dir
|
||||||
|
# LIBLASTFM_LIBRARY, the path to liblastfm
|
||||||
|
# LIBLASTFM_FOUND, whether liblastfm was found
|
||||||
|
|
||||||
|
|
||||||
|
find_path(LIBLASTFM_INCLUDE_DIR NAMES Audioscrobbler
|
||||||
|
HINTS
|
||||||
|
~/usr/include
|
||||||
|
/opt/local/include
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
/opt/kde4/include
|
||||||
|
${KDE4_INCLUDE_DIR}
|
||||||
|
PATH_SUFFIXES lastfm
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library( LIBLASTFM_LIBRARY NAMES lastfm
|
||||||
|
PATHS
|
||||||
|
~/usr/lib
|
||||||
|
/opt/local/lib
|
||||||
|
/usr/lib
|
||||||
|
/usr/lib64
|
||||||
|
/usr/local/lib
|
||||||
|
/opt/kde4/lib
|
||||||
|
${KDE4_LIB_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY)
|
||||||
|
set(LIBLASTFM_FOUND TRUE)
|
||||||
|
message(STATUS "Found liblastfm: ${LIBLASTFM_INCLUDE_DIR}, ${LIBLASTFM_LIBRARY}")
|
||||||
|
else(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY)
|
||||||
|
set(LIBLASTFM_FOUND FALSE)
|
||||||
|
if (LIBLASTFM_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could NOT find required package LibLastFm")
|
||||||
|
endif(LIBLASTFM_FIND_REQUIRED)
|
||||||
|
endif(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY)
|
||||||
|
|
||||||
|
mark_as_advanced(LIBLASTFM_INCLUDE_DIR LIBLASTFM_LIBRARY)
|
113
CMakeModules/FindLibraryWithDebug.cmake
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
#
|
||||||
|
# FIND_LIBRARY_WITH_DEBUG
|
||||||
|
# -> enhanced FIND_LIBRARY to allow the search for an
|
||||||
|
# optional debug library with a WIN32_DEBUG_POSTFIX similar
|
||||||
|
# to CMAKE_DEBUG_POSTFIX when creating a shared lib
|
||||||
|
# it has to be the second and third argument
|
||||||
|
|
||||||
|
# Copyright (c) 2007, Christian Ehrlicher, <ch.ehrlicher@gmx.de>
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
MACRO(FIND_LIBRARY_WITH_DEBUG var_name win32_dbg_postfix_name dgb_postfix libname)
|
||||||
|
|
||||||
|
IF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
|
||||||
|
|
||||||
|
# no WIN32_DEBUG_POSTFIX -> simply pass all arguments to FIND_LIBRARY
|
||||||
|
FIND_LIBRARY(${var_name}
|
||||||
|
${win32_dbg_postfix_name}
|
||||||
|
${dgb_postfix}
|
||||||
|
${libname}
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
|
||||||
|
ELSE(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
|
||||||
|
|
||||||
|
IF(NOT WIN32)
|
||||||
|
# on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
|
||||||
|
|
||||||
|
FIND_LIBRARY(${var_name} ${libname} ${ARGN})
|
||||||
|
|
||||||
|
ELSE(NOT WIN32)
|
||||||
|
|
||||||
|
# 1. get all possible libnames
|
||||||
|
SET(args ${ARGN})
|
||||||
|
SET(newargs "")
|
||||||
|
SET(libnames_release "")
|
||||||
|
SET(libnames_debug "")
|
||||||
|
|
||||||
|
LIST(LENGTH args listCount)
|
||||||
|
|
||||||
|
IF("${libname}" STREQUAL "NAMES")
|
||||||
|
SET(append_rest 0)
|
||||||
|
LIST(APPEND args " ")
|
||||||
|
|
||||||
|
FOREACH(i RANGE ${listCount})
|
||||||
|
LIST(GET args ${i} val)
|
||||||
|
|
||||||
|
IF(append_rest)
|
||||||
|
LIST(APPEND newargs ${val})
|
||||||
|
ELSE(append_rest)
|
||||||
|
IF("${val}" STREQUAL "PATHS")
|
||||||
|
LIST(APPEND newargs ${val})
|
||||||
|
SET(append_rest 1)
|
||||||
|
ELSE("${val}" STREQUAL "PATHS")
|
||||||
|
LIST(APPEND libnames_release "${val}")
|
||||||
|
LIST(APPEND libnames_debug "${val}${dgb_postfix}")
|
||||||
|
ENDIF("${val}" STREQUAL "PATHS")
|
||||||
|
ENDIF(append_rest)
|
||||||
|
|
||||||
|
ENDFOREACH(i)
|
||||||
|
|
||||||
|
ELSE("${libname}" STREQUAL "NAMES")
|
||||||
|
|
||||||
|
# just one name
|
||||||
|
LIST(APPEND libnames_release "${libname}")
|
||||||
|
LIST(APPEND libnames_debug "${libname}${dgb_postfix}")
|
||||||
|
|
||||||
|
SET(newargs ${args})
|
||||||
|
|
||||||
|
ENDIF("${libname}" STREQUAL "NAMES")
|
||||||
|
|
||||||
|
# search the release lib
|
||||||
|
FIND_LIBRARY(${var_name}_RELEASE
|
||||||
|
NAMES ${libnames_release}
|
||||||
|
${newargs}
|
||||||
|
)
|
||||||
|
|
||||||
|
# search the debug lib
|
||||||
|
FIND_LIBRARY(${var_name}_DEBUG
|
||||||
|
NAMES ${libnames_debug}
|
||||||
|
${newargs}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(${var_name}_RELEASE AND ${var_name}_DEBUG)
|
||||||
|
|
||||||
|
# both libs found
|
||||||
|
SET(${var_name} optimized ${${var_name}_RELEASE}
|
||||||
|
debug ${${var_name}_DEBUG})
|
||||||
|
|
||||||
|
ELSE(${var_name}_RELEASE AND ${var_name}_DEBUG)
|
||||||
|
|
||||||
|
IF(${var_name}_RELEASE)
|
||||||
|
|
||||||
|
# only release found
|
||||||
|
SET(${var_name} ${${var_name}_RELEASE})
|
||||||
|
|
||||||
|
ELSE(${var_name}_RELEASE)
|
||||||
|
|
||||||
|
# only debug (or nothing) found
|
||||||
|
SET(${var_name} ${${var_name}_DEBUG})
|
||||||
|
|
||||||
|
ENDIF(${var_name}_RELEASE)
|
||||||
|
|
||||||
|
ENDIF(${var_name}_RELEASE AND ${var_name}_DEBUG)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(${var_name}_RELEASE)
|
||||||
|
MARK_AS_ADVANCED(${var_name}_DEBUG)
|
||||||
|
|
||||||
|
ENDIF(NOT WIN32)
|
||||||
|
|
||||||
|
ENDIF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
|
||||||
|
|
||||||
|
ENDMACRO(FIND_LIBRARY_WITH_DEBUG)
|
89
CMakeModules/FindOggVorbis.cmake
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# - Try to find the OggVorbis libraries
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# OGGVORBIS_FOUND - system has OggVorbis
|
||||||
|
# OGGVORBIS_VERSION - set either to 1 or 2
|
||||||
|
# OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
|
||||||
|
# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
|
||||||
|
# OGG_LIBRARY - The Ogg library
|
||||||
|
# VORBIS_LIBRARY - The Vorbis library
|
||||||
|
# VORBISFILE_LIBRARY - The VorbisFile library
|
||||||
|
# VORBISENC_LIBRARY - The VorbisEnc library
|
||||||
|
|
||||||
|
# Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
|
||||||
|
include (CheckLibraryExists)
|
||||||
|
|
||||||
|
find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
||||||
|
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
|
||||||
|
|
||||||
|
find_library(OGG_LIBRARY NAMES ogg)
|
||||||
|
find_library(VORBIS_LIBRARY NAMES vorbis)
|
||||||
|
find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
|
||||||
|
find_library(VORBISENC_LIBRARY NAMES vorbisenc)
|
||||||
|
|
||||||
|
mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR
|
||||||
|
OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
|
||||||
|
|
||||||
|
|
||||||
|
if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
|
||||||
|
set(OGGVORBIS_FOUND TRUE)
|
||||||
|
|
||||||
|
set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
|
||||||
|
|
||||||
|
set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
|
||||||
|
check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
|
||||||
|
|
||||||
|
if (HAVE_LIBVORBISENC2)
|
||||||
|
set (OGGVORBIS_VERSION 2)
|
||||||
|
else (HAVE_LIBVORBISENC2)
|
||||||
|
set (OGGVORBIS_VERSION 1)
|
||||||
|
endif (HAVE_LIBVORBISENC2)
|
||||||
|
|
||||||
|
else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
|
||||||
|
set (OGGVORBIS_VERSION)
|
||||||
|
set(OGGVORBIS_FOUND FALSE)
|
||||||
|
endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
|
||||||
|
|
||||||
|
|
||||||
|
if (OGGVORBIS_FOUND)
|
||||||
|
if (NOT OggVorbis_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
|
||||||
|
endif (NOT OggVorbis_FIND_QUIETLY)
|
||||||
|
else (OGGVORBIS_FOUND)
|
||||||
|
if (OggVorbis_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could NOT find OggVorbis libraries")
|
||||||
|
endif (OggVorbis_FIND_REQUIRED)
|
||||||
|
if (NOT OggVorbis_FIND_QUITELY)
|
||||||
|
message(STATUS "Could NOT find OggVorbis libraries")
|
||||||
|
endif (NOT OggVorbis_FIND_QUITELY)
|
||||||
|
endif (OGGVORBIS_FOUND)
|
||||||
|
|
||||||
|
#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
|
||||||
|
#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
|
||||||
|
#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
|
||||||
|
#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
|
||||||
|
#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
|
||||||
|
#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
|
||||||
|
|
||||||
|
#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
||||||
|
# message(STATUS "Ogg/Vorbis found")
|
||||||
|
# set (VORBIS_LIBS "-lvorbis -logg")
|
||||||
|
# set (VORBISFILE_LIBS "-lvorbisfile")
|
||||||
|
# set (VORBISENC_LIBS "-lvorbisenc")
|
||||||
|
# set (OGGVORBIS_FOUND TRUE)
|
||||||
|
# if (HAVE_LIBVORBISENC2)
|
||||||
|
# set (HAVE_VORBIS 2)
|
||||||
|
# else (HAVE_LIBVORBISENC2)
|
||||||
|
# set (HAVE_VORBIS 1)
|
||||||
|
# endif (HAVE_LIBVORBISENC2)
|
||||||
|
#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
||||||
|
# message(STATUS "Ogg/Vorbis not found")
|
||||||
|
#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
||||||
|
|
89
CMakeModules/FindTaglib.cmake
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# - Try to find the Taglib library
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# TAGLIB_FOUND - system has the taglib library
|
||||||
|
# TAGLIB_CFLAGS - the taglib cflags
|
||||||
|
# TAGLIB_LIBRARIES - The libraries needed to use taglib
|
||||||
|
|
||||||
|
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
IF(TAGLIB_FOUND)
|
||||||
|
MESSAGE(STATUS "Using manually specified taglib locations")
|
||||||
|
ELSE()
|
||||||
|
|
||||||
|
if(NOT TAGLIB_MIN_VERSION)
|
||||||
|
set(TAGLIB_MIN_VERSION "1.6")
|
||||||
|
endif(NOT TAGLIB_MIN_VERSION)
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
|
||||||
|
${BIN_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
#reset vars
|
||||||
|
set(TAGLIB_LIBRARIES)
|
||||||
|
set(TAGLIB_CFLAGS)
|
||||||
|
|
||||||
|
# MESSAGE( STATUS "PATHS: ${PATHS}")
|
||||||
|
# if taglib-config has been found
|
||||||
|
if(TAGLIBCONFIG_EXECUTABLE)
|
||||||
|
|
||||||
|
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
|
||||||
|
|
||||||
|
if(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
|
||||||
|
message(STATUS "TagLib version not found: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
|
||||||
|
set(TAGLIB_FOUND FALSE)
|
||||||
|
else(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
|
||||||
|
|
||||||
|
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
|
||||||
|
|
||||||
|
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
|
||||||
|
|
||||||
|
if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
|
||||||
|
set(TAGLIB_FOUND TRUE)
|
||||||
|
# message(STATUS "Found taglib: ${TAGLIB_LIBRARIES}")
|
||||||
|
endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
|
||||||
|
string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
|
||||||
|
endif(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
|
||||||
|
mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
|
||||||
|
|
||||||
|
else(TAGLIBCONFIG_EXECUTABLE)
|
||||||
|
|
||||||
|
include(FindLibraryWithDebug)
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_path(TAGLIB_CFLAGS
|
||||||
|
NAMES
|
||||||
|
tag.h
|
||||||
|
PATH_SUFFIXES taglib
|
||||||
|
PATHS
|
||||||
|
${KDE4_INCLUDE_DIR}
|
||||||
|
${INCLUDE_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library_with_debug(TAGLIB_LIBRARIES
|
||||||
|
WIN32_DEBUG_POSTFIX d
|
||||||
|
NAMES tag
|
||||||
|
PATHS
|
||||||
|
${KDE4_LIB_DIR}
|
||||||
|
${LIB_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(Taglib DEFAULT_MSG
|
||||||
|
TAGLIB_INCLUDES TAGLIB_LIBRARIES)
|
||||||
|
endif(TAGLIBCONFIG_EXECUTABLE)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
if(TAGLIB_FOUND)
|
||||||
|
if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
|
||||||
|
message(STATUS "Found TagLib: ${TAGLIB_LIBRARIES}")
|
||||||
|
endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
|
||||||
|
else(TAGLIB_FOUND)
|
||||||
|
if(Taglib_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find Taglib")
|
||||||
|
endif(Taglib_FIND_REQUIRED)
|
||||||
|
endif(TAGLIB_FOUND)
|
1
CMakeModules/README.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FindTaglib.cmake taken from KDE4 kdelibs/cmake/Modules
|
621
LICENSE.txt
Normal file
@@ -0,0 +1,621 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
87
README
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
Quickstart on Ubuntu
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
sudo apt-get install build-essential cmake libtag1c2a libtag1-dev liblastfm-dev \
|
||||||
|
libqt4-dev libqt4-sql-sqlite libvorbis-dev libmad0-dev \
|
||||||
|
libasound2-dev libboost-dev zlib1g-dev libgnutls-dev pkg-config
|
||||||
|
|
||||||
|
|
||||||
|
Gloox 1.0 (XMPP library)
|
||||||
|
------------------------
|
||||||
|
See: http://camaya.net/glooxdownload
|
||||||
|
You need to build gloox 1.0 from source, Ubuntu 10.04 only packages v0.9.
|
||||||
|
|
||||||
|
$ # Download and unpack tarball
|
||||||
|
$ CXXFLAGS=-fPIC ./configure --without-openssl --with-gnutls --without-libidn --with-zlib --without-examples --without-tests
|
||||||
|
$ CXXFLAGS=-fPIC make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
QJson (Qt JSON library)
|
||||||
|
-----------------------
|
||||||
|
On Ubuntu 10.04:
|
||||||
|
$ sudo apt-get install libqjson-dev
|
||||||
|
|
||||||
|
Otherwise:
|
||||||
|
See: http://sourceforge.net/projects/qjson/files/ (developed using 0.7.1)
|
||||||
|
|
||||||
|
$ # Download and unpack tarball
|
||||||
|
$ ./configure && make
|
||||||
|
$ sudo make install
|
||||||
|
|
||||||
|
Now compile Tomahawk
|
||||||
|
-------------------
|
||||||
|
$ sudo ldconfig -v | grep -Ei 'qjson|gloox'
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
$ cmake ..
|
||||||
|
$ make
|
||||||
|
$ cd ..
|
||||||
|
$ ./tomahawk
|
||||||
|
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
CMake 2.8.0 http://www.cmake.org/
|
||||||
|
Qt 4.6.2 http://qt.nokia.com/
|
||||||
|
QJson 0.7.1 http://qjson.sourceforge.net/
|
||||||
|
Gloox 1.0 (0.9.x will fail) http://camaya.net/gloox/
|
||||||
|
SQLite 3.6.22 http://www.sqlite.org/
|
||||||
|
TagLib 1.6.2 http://developer.kde.org/~wheeler/taglib.html
|
||||||
|
Boost 1.3x http://www.boost.org/
|
||||||
|
|
||||||
|
Unless you enable the headless mode (no GUI), we also require the following libraries:
|
||||||
|
|
||||||
|
libmad 0.15.1b http://www.underbit.com/products/mad/
|
||||||
|
libvorbis 1.2.3 http://xiph.org/vorbis/
|
||||||
|
libogg 1.1.4 http://xiph.org/ogg/
|
||||||
|
liblastfm 0.3.0 http://github.com/mxcl/liblastfm/
|
||||||
|
|
||||||
|
Third party libraries that we ship with our source:
|
||||||
|
|
||||||
|
RtAudio 4.0.7 http://www.music.mcgill.ca/~gary/rtaudio/
|
||||||
|
MiniUPnP http://miniupnp.free.fr/
|
||||||
|
|
||||||
|
|
||||||
|
To build the app:
|
||||||
|
-----------------
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
|
||||||
|
(Pick one of the following two choices. If unsure pick the second one, you probably want a GUI)
|
||||||
|
$ cmake -Dgui=no .. # enables headless mode, build without GUI
|
||||||
|
$ cmake .. # normal build including GUI
|
||||||
|
|
||||||
|
$ make
|
||||||
|
|
||||||
|
To run the app:
|
||||||
|
---------------
|
||||||
|
$ cd .. # return to the top-level tomahawk dir
|
||||||
|
|
||||||
|
(Only run the next two commands if you installed any of the dependencies from source on Linux)
|
||||||
|
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
||||||
|
$ sudo ldconfig -v
|
||||||
|
|
||||||
|
$ ./tomahawk
|
||||||
|
|
||||||
|
Enjoy!
|
28
admin/mac/Info.plist
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>tomahawk</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.tomahawk.Tomahawk</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>0.0.1.0</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>0.0.1</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>tomahawk</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>tomahawk.icns</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>Tomahawk</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.5.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
64
admin/mac/add-Qt-to-bundle.sh
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# author: max@last.fm
|
||||||
|
# usage: Run from inside the bundle root directory, eg. Last.fm.app
|
||||||
|
# The first parameter should be the QtFrameworks to copy.
|
||||||
|
# Remaining parameters are plugins to copy, directories and files are
|
||||||
|
# valid.
|
||||||
|
# eg: add-Qt-to-bundle.sh 'QtCore QtGui QtXml' \
|
||||||
|
# imageformats \
|
||||||
|
# sqldrivers/libsqlite.dylib
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
if [[ ! -d "$QTDIR/lib/QtCore.framework" ]]
|
||||||
|
then
|
||||||
|
# this dir is the location of install for the official Trolltech dmg
|
||||||
|
if [[ -d /Library/Frameworks/QtCore.framework ]]
|
||||||
|
then
|
||||||
|
QT_FRAMEWORKS_DIR=/Library/Frameworks
|
||||||
|
QT_PLUGINS_DIR=/Developer/Applications/Qt/plugins
|
||||||
|
fi
|
||||||
|
elif [[ $QTDIR ]]
|
||||||
|
then
|
||||||
|
QT_FRAMEWORKS_DIR="$QTDIR/lib"
|
||||||
|
QT_PLUGINS_DIR="$QTDIR/plugins"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $QTDIR ]
|
||||||
|
then
|
||||||
|
echo QTDIR must be set, or install the official Qt dmg
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#first frameworks
|
||||||
|
mkdir -p Contents/Frameworks
|
||||||
|
for x in $1
|
||||||
|
do
|
||||||
|
echo "C $x"
|
||||||
|
cp -R $QT_FRAMEWORKS_DIR/$x.framework Contents/Frameworks/
|
||||||
|
done
|
||||||
|
|
||||||
|
#plugins
|
||||||
|
shift
|
||||||
|
mkdir -p Contents/MacOS
|
||||||
|
while (( "$#" ))
|
||||||
|
do
|
||||||
|
echo "C $1"
|
||||||
|
|
||||||
|
if [[ -d $QT_PLUGINS_DIR/$1 ]]
|
||||||
|
then
|
||||||
|
cp -R $QT_PLUGINS_DIR/$1 Contents/MacOS
|
||||||
|
else
|
||||||
|
dir=$(basename $(dirname $1))
|
||||||
|
mkdir Contents/MacOS/$dir
|
||||||
|
cp $QT_PLUGINS_DIR/$1 Contents/MacOS/$dir
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
#cleanup
|
||||||
|
find Contents/Frameworks -name Headers -o -name \*.prl -o -name \*_debug | xargs rm -rf
|
||||||
|
find Contents -name \*_debug -o -name \*_debug.dylib | xargs rm
|
48
admin/mac/build-release-osx.sh
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Usage: dist/build-relese-osx.sh [-j] [--no-clean]
|
||||||
|
#
|
||||||
|
# Adding the -j parameter results in building a japanese version.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
function header {
|
||||||
|
echo -e "\033[0;34m==>\033[0;0;1m $1 \033[0;0m"
|
||||||
|
}
|
||||||
|
|
||||||
|
function die {
|
||||||
|
exit_code=$?
|
||||||
|
echo $1
|
||||||
|
exit $exit_code
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
ROOT=`pwd`
|
||||||
|
|
||||||
|
QTDIR=`which qmake`
|
||||||
|
QTDIR=`dirname $QTDIR`
|
||||||
|
QTDIR=`dirname $QTDIR`
|
||||||
|
test -L "$QTDIR" && QTDIR=`readlink $QTDIR`
|
||||||
|
|
||||||
|
export QMAKESPEC='macx-g++'
|
||||||
|
export QTDIR
|
||||||
|
export VERSION
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
CLEAN='1'
|
||||||
|
BUILD='1'
|
||||||
|
NOTQUICK='1'
|
||||||
|
CREATEDMG='1'
|
||||||
|
|
||||||
|
header addQt
|
||||||
|
cd tomahawk.app
|
||||||
|
# $ROOT/admin/mac/add-Qt-to-bundle.sh \
|
||||||
|
# 'QtCore QtGui QtXml QtNetwork QtSql'
|
||||||
|
|
||||||
|
header deposx
|
||||||
|
$ROOT/admin/mac/deposx.sh
|
||||||
|
|
||||||
|
header Done!
|
||||||
|
|
73
admin/mac/deposx.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# author: max@last.fm, chris@last.fm
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z $QTDIR ]
|
||||||
|
then
|
||||||
|
echo QTDIR must be set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd Contents
|
||||||
|
|
||||||
|
QTLIBS=`ls Frameworks | cut -d. -f1`
|
||||||
|
LIBS=`cd MacOS && ls -fR1 | grep dylib`
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
function deposx_change
|
||||||
|
{
|
||||||
|
echo "D \`$1'"
|
||||||
|
echo $QTDIR
|
||||||
|
|
||||||
|
|
||||||
|
for y in $QTLIBS
|
||||||
|
do
|
||||||
|
install_name_tool -change $QTDIR/lib/$y.framework/Versions/4/$y \
|
||||||
|
@executable_path/../Frameworks/$y.framework/Versions/4/$y \
|
||||||
|
"$1"
|
||||||
|
|
||||||
|
install_name_tool -change $QTDIR/Cellar/qt/4.6.2/lib/$y.framework/Versions/4/$y \
|
||||||
|
@executable_path/../Frameworks/$y.framework/Versions/4/$y \
|
||||||
|
"$1"
|
||||||
|
done
|
||||||
|
|
||||||
|
for y in $LIBS
|
||||||
|
do
|
||||||
|
install_name_tool -change $y \
|
||||||
|
@executable_path/$y \
|
||||||
|
"$1"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
# first all libraries and executables
|
||||||
|
find MacOS -type f -a -perm -100 | while read x
|
||||||
|
do
|
||||||
|
echo $x
|
||||||
|
y=$(file "$x" | grep 'Mach-O')
|
||||||
|
test -n "$y" && deposx_change "$x"
|
||||||
|
|
||||||
|
install_name_tool -change liblastfm.0.dylib @executable_path/liblastfm.0.dylib $x
|
||||||
|
install_name_tool -change /usr/local/Cellar/gloox/1.0/lib/libgloox.8.dylib @executable_path/libgloox.8.dylib $x
|
||||||
|
install_name_tool -change /usr/local/lib/libgloox.8.dylib @executable_path/libgloox.8.dylib $x
|
||||||
|
install_name_tool -change /usr/local/Cellar/taglib/1.6/lib/libtag.1.dylib @executable_path/libtag.1.dylib $x
|
||||||
|
install_name_tool -change /usr/local/Cellar/libogg/1.2.0/lib/libogg.0.dylib @executable_path/libogg.0.dylib $x
|
||||||
|
install_name_tool -change /usr/local/Cellar/libvorbis/1.3.1/lib/libvorbisfile.3.dylib @executable_path/libvorbisfile.3.dylib $x
|
||||||
|
install_name_tool -change /usr/local/Cellar/mad/0.15.1b/lib/libmad.0.dylib @executable_path/libmad.0.dylib $x
|
||||||
|
done
|
||||||
|
|
||||||
|
deposx_change MacOS/libqjson.0.7.1.dylib
|
||||||
|
deposx_change MacOS/liblastfm.0.dylib
|
||||||
|
|
||||||
|
# now Qt
|
||||||
|
for x in $QTLIBS
|
||||||
|
do
|
||||||
|
echo `pwd`
|
||||||
|
# ls -l Frameworks/$x.framework/Versions/4/$x
|
||||||
|
deposx_change Frameworks/$x.framework/Versions/4/$x
|
||||||
|
install_name_tool -id @executable_path/../Frameworks/$x.framework/Versions/4/$x \
|
||||||
|
Frameworks/$x.framework/Versions/4/$x
|
||||||
|
done
|
3
admin/win/README.txt
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
# windres.exe tomahawk.rx -O coff -o tomahawk.res
|
||||||
|
|
||||||
|
# SEE: http://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable
|
124
admin/win/tomahawk.nsi
Executable file
@@ -0,0 +1,124 @@
|
|||||||
|
; assuming the script is in ROOT/admin/win/
|
||||||
|
!define ROOTDIR "../.."
|
||||||
|
|
||||||
|
!include "MUI2.nsh"
|
||||||
|
|
||||||
|
Name "Tomahawk"
|
||||||
|
!define MUI_NAME "Tomahawk"
|
||||||
|
!define MUI_PRODUCT "Tomahawk"
|
||||||
|
!define MUI_FILE "Tomahawk"
|
||||||
|
!define MUI_VERSION "Alpha"
|
||||||
|
!define MUI_BRANDINGTEXT "Tomahawk-Player Alpha Test"
|
||||||
|
CRCCheck On
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OutFile "tomahawk-setup-alpha.exe"
|
||||||
|
;ShowInstDetails "nevershow"
|
||||||
|
ShowUninstDetails "nevershow"
|
||||||
|
;SetCompressor "bzip2"
|
||||||
|
|
||||||
|
!define MUI_ICON "..\..\data\icons\tomahawk.ico"
|
||||||
|
!define MUI_UNICON "..\..\data\icons\tomahawk.ico"
|
||||||
|
;!define MUI_SPECIALBITMAP "Bitmap.bmp"
|
||||||
|
|
||||||
|
|
||||||
|
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Modern UI Configuration
|
||||||
|
!define MUI_WELCOMEPAGE_TEXT "This is an Alpha release, and is still buggy.$\n$\nPlease join #tomahawk-player on irc.freenode.net"
|
||||||
|
!insertmacro MUI_PAGE_WELCOME
|
||||||
|
|
||||||
|
!insertmacro MUI_PAGE_LICENSE "${ROOTDIR}\LICENSE.txt"
|
||||||
|
;;!insertmacro MUI_PAGE_COMPONENTS
|
||||||
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
|
!define MUI_FINISHPAGE_RUN "$INSTDIR\tomahawk.exe"
|
||||||
|
!insertmacro MUI_PAGE_FINISH
|
||||||
|
|
||||||
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
;Modern UI System
|
||||||
|
;!insertmacro MUI_SYSTEM
|
||||||
|
|
||||||
|
LicenseData "${ROOTDIR}\LICENSE.txt"
|
||||||
|
|
||||||
|
Section "install"
|
||||||
|
|
||||||
|
;Add files
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
|
|
||||||
|
;Path to our DLL cache
|
||||||
|
!define DLLS "${ROOTDIR}\admin\win\dlls"
|
||||||
|
|
||||||
|
File "${ROOTDIR}\build\tomahawk.exe"
|
||||||
|
File "${ROOTDIR}\LICENSE.txt"
|
||||||
|
|
||||||
|
; QT stuff:
|
||||||
|
File "${DLLS}\QtCore4.dll"
|
||||||
|
File "${DLLS}\QtGui4.dll"
|
||||||
|
File "${DLLS}\QtNetwork4.dll"
|
||||||
|
File "${DLLS}\QtSql4.dll"
|
||||||
|
File "${DLLS}\QtXml4.dll"
|
||||||
|
SetOutPath "$INSTDIR\sqldrivers"
|
||||||
|
File "${DLLS}\sqldrivers\qsqlite4.dll"
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
|
|
||||||
|
; Cygwin/c++ stuff
|
||||||
|
File "${DLLS}\cygmad-0.dll"
|
||||||
|
File "${DLLS}\libgcc_s_dw2-1.dll"
|
||||||
|
File "${DLLS}\mingwm10.dll"
|
||||||
|
|
||||||
|
; Audio stuff
|
||||||
|
File "${DLLS}\libmad.dll"
|
||||||
|
File "${DLLS}\librtaudio.dll"
|
||||||
|
|
||||||
|
; Other
|
||||||
|
File "${DLLS}\libqjson.dll"
|
||||||
|
File "${DLLS}\libqxtweb-standalone.dll"
|
||||||
|
File "${DLLS}\libtag.dll"
|
||||||
|
|
||||||
|
;create desktop shortcut
|
||||||
|
CreateShortCut "$DESKTOP\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_FILE}.exe" ""
|
||||||
|
|
||||||
|
;create start-menu items
|
||||||
|
CreateDirectory "$SMPROGRAMS\${MUI_PRODUCT}"
|
||||||
|
CreateShortCut "$SMPROGRAMS\${MUI_PRODUCT}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
|
||||||
|
CreateShortCut "$SMPROGRAMS\${MUI_PRODUCT}\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_FILE}.exe" "" "$INSTDIR\${MUI_FILE}.exe" 0
|
||||||
|
|
||||||
|
;write uninstall information to the registry
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayName" "${MUI_PRODUCT} (remove only)"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "UninstallString" "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Uninstaller Section
|
||||||
|
Section "Uninstall"
|
||||||
|
|
||||||
|
;Delete Files
|
||||||
|
RMDir /r "$INSTDIR\*.*"
|
||||||
|
|
||||||
|
;Remove the installation directory
|
||||||
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
|
;Delete Start Menu Shortcuts
|
||||||
|
Delete "$DESKTOP\${MUI_PRODUCT}.lnk"
|
||||||
|
Delete "$SMPROGRAMS\${MUI_PRODUCT}\*.*"
|
||||||
|
RmDir "$SMPROGRAMS\${MUI_PRODUCT}"
|
||||||
|
|
||||||
|
;Delete Uninstaller And Unistall Registry Entries
|
||||||
|
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${MUI_PRODUCT}"
|
||||||
|
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
|
||||||
|
Function un.onUninstSuccess
|
||||||
|
MessageBox MB_OK "You have successfully uninstalled ${MUI_PRODUCT}."
|
||||||
|
FunctionEnd
|
1
admin/win/tomahawk.rc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ID ICON "data/tomahawk_logo_32x32.ico"
|
44
alsa-playback/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
PROJECT(alsaplayback)
|
||||||
|
|
||||||
|
find_package( Qt4 REQUIRED )
|
||||||
|
|
||||||
|
include( ${QT_USE_FILE} )
|
||||||
|
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
|
||||||
|
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
#SET(CMAKE_INSTALL_PREFIX ".")
|
||||||
|
|
||||||
|
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
#ADD_DEFINITIONS(-Wall -O2 -DNDEBUG)
|
||||||
|
#ADD_DEFINITIONS(-fPIC)
|
||||||
|
|
||||||
|
SET(AUDIO_LIBS "")
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
SET(AUDIO_LIBS "asound")
|
||||||
|
endif(UNIX AND NOT APPLE)
|
||||||
|
|
||||||
|
set( alsaplaybackSources
|
||||||
|
alsaplayback.cpp
|
||||||
|
alsaaudio.cpp
|
||||||
|
xconvert.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set( alsaplaybackHeaders
|
||||||
|
alsaplayback.h
|
||||||
|
)
|
||||||
|
|
||||||
|
qt4_wrap_cpp( alsaplaybackMoc ${alsaplaybackHeaders} )
|
||||||
|
SET(final_src ${alsaplaybackMoc} ${alsaplaybackSources} ${alsaplaybackHeaders})
|
||||||
|
|
||||||
|
ADD_LIBRARY(alsaplayback STATIC ${final_src})
|
||||||
|
|
||||||
|
target_link_libraries( alsaplayback
|
||||||
|
${QT_LIBRARIES}
|
||||||
|
${AUDIO_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
#INSTALL(TARGETS alsaplayback ARCHIVE DESTINATION lib)
|
920
alsa-playback/alsaaudio.cpp
Normal file
@@ -0,0 +1,920 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007 by John Stamp, <jstamp@users.sourceforge.net> *
|
||||||
|
* Copyright (C) 2007 by Max Howell, Last.fm Ltd. *
|
||||||
|
* Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com> *
|
||||||
|
* *
|
||||||
|
* Large portions of this code are shamelessly copied from audio.c: *
|
||||||
|
* The XMMS ALSA output plugin *
|
||||||
|
* Copyright (C) 2001-2003 Matthieu Sozeau <mattam@altern.org> *
|
||||||
|
* Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, *
|
||||||
|
* Thomas Nilsson and 4Front Technologies *
|
||||||
|
* Copyright (C) 1999-2007 Haavard Kvaalen *
|
||||||
|
* Copyright (C) 2005 Takashi Iwai *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "alsaaudio.h"
|
||||||
|
|
||||||
|
#include <qendian.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
//no debug
|
||||||
|
#define snd_pcm_hw_params_dump( hwparams, logs )
|
||||||
|
#define snd_pcm_sw_params_dump( x, y )
|
||||||
|
#define snd_pcm_dump( x, y )
|
||||||
|
|
||||||
|
pthread_t AlsaAudio::audio_thread;
|
||||||
|
|
||||||
|
char* AlsaAudio::thread_buffer = NULL;
|
||||||
|
int AlsaAudio::thread_buffer_size = 0;
|
||||||
|
int AlsaAudio::rd_index = 0;
|
||||||
|
int AlsaAudio::wr_index = 0;
|
||||||
|
unsigned int AlsaAudio::pcmCounter = 0;
|
||||||
|
|
||||||
|
snd_output_t* AlsaAudio::logs = NULL;
|
||||||
|
bool AlsaAudio::going = false;
|
||||||
|
snd_pcm_t *AlsaAudio::alsa_pcm = NULL;
|
||||||
|
|
||||||
|
ssize_t AlsaAudio::hw_period_size_in = 0;
|
||||||
|
snd_format* AlsaAudio::inputf = NULL;
|
||||||
|
snd_format* AlsaAudio::outputf = NULL;
|
||||||
|
float AlsaAudio::volume = 1.0;
|
||||||
|
bool AlsaAudio::paused = false;
|
||||||
|
|
||||||
|
convert_func_t AlsaAudio::alsa_convert_func = NULL;
|
||||||
|
convert_channel_func_t AlsaAudio::alsa_stereo_convert_func = NULL;
|
||||||
|
convert_freq_func_t AlsaAudio::alsa_frequency_convert_func = NULL;
|
||||||
|
xmms_convert_buffers* AlsaAudio::convertb = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
AlsaAudio::AlsaAudio()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AlsaAudio::~AlsaAudio()
|
||||||
|
{
|
||||||
|
// Close here just to be sure
|
||||||
|
// These are safe to call more than once
|
||||||
|
stopPlayback();
|
||||||
|
alsaClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Device Detection
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::getCards( void )
|
||||||
|
{
|
||||||
|
int card = -1;
|
||||||
|
int err = 0;
|
||||||
|
m_devices.clear();
|
||||||
|
|
||||||
|
// First add the default PCM device
|
||||||
|
AlsaDeviceInfo dev;
|
||||||
|
dev.name = "Default PCM device (default)";
|
||||||
|
dev.device = "default";
|
||||||
|
m_devices.push_back( dev );
|
||||||
|
|
||||||
|
if ( (err = snd_card_next( &card )) != 0 )
|
||||||
|
goto getCardsFailed;
|
||||||
|
|
||||||
|
while ( card > -1 )
|
||||||
|
{
|
||||||
|
getDevicesForCard( card );
|
||||||
|
if ( (err = snd_card_next( &card )) != 0 )
|
||||||
|
goto getCardsFailed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_devices.size();
|
||||||
|
|
||||||
|
getCardsFailed:
|
||||||
|
qDebug() << __PRETTY_FUNCTION__ << "failed:" << snd_strerror( -err );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::getDevicesForCard( int card )
|
||||||
|
{
|
||||||
|
int pcm_device = -1, err;
|
||||||
|
snd_pcm_info_t *pcm_info;
|
||||||
|
snd_ctl_t *ctl;
|
||||||
|
char *alsa_name;
|
||||||
|
QString cardName = "Unknown soundcard";
|
||||||
|
QString device_name = QString( "hw:%1" ).arg( card );
|
||||||
|
|
||||||
|
if ((err = snd_ctl_open( &ctl, device_name.toAscii(), 0 )) < 0) {
|
||||||
|
qDebug() << "Failed:" << snd_strerror( -err );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((err = snd_card_get_name( card, &alsa_name )) != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Failed:" << snd_strerror( -err );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cardName = alsa_name;
|
||||||
|
|
||||||
|
snd_pcm_info_alloca( &pcm_info );
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if ((err = snd_ctl_pcm_next_device( ctl, &pcm_device )) < 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Failed:" << snd_strerror( -err );
|
||||||
|
pcm_device = -1;
|
||||||
|
}
|
||||||
|
if (pcm_device < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
snd_pcm_info_set_device( pcm_info, pcm_device );
|
||||||
|
snd_pcm_info_set_subdevice( pcm_info, 0 );
|
||||||
|
snd_pcm_info_set_stream( pcm_info, SND_PCM_STREAM_PLAYBACK );
|
||||||
|
|
||||||
|
if ((err = snd_ctl_pcm_info( ctl, pcm_info )) < 0)
|
||||||
|
{
|
||||||
|
if ( err != -ENOENT )
|
||||||
|
qDebug() << "Failed: snd_ctl_pcm_info() failed"
|
||||||
|
"(" << card << ":" << pcm_device << "): "
|
||||||
|
<< snd_strerror( -err );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlsaDeviceInfo dev;
|
||||||
|
dev.device = QString( "hw:%1,%2" )
|
||||||
|
.arg( card )
|
||||||
|
.arg( pcm_device );
|
||||||
|
dev.name = QString( "%1: %2 (%3)" )
|
||||||
|
.arg( cardName )
|
||||||
|
.arg( snd_pcm_info_get_name( pcm_info ) )
|
||||||
|
.arg( dev.device );
|
||||||
|
|
||||||
|
m_devices.push_back( dev );
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_ctl_close( ctl );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AlsaDeviceInfo
|
||||||
|
AlsaAudio::getDeviceInfo( int device )
|
||||||
|
{
|
||||||
|
return m_devices[device];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
Device Setup
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
bool
|
||||||
|
AlsaAudio::alsaOpen( QString device, AFormat format, unsigned int rate,
|
||||||
|
unsigned int channels, snd_pcm_uframes_t periodSize,
|
||||||
|
unsigned int periodCount, int minBufferCapacity )
|
||||||
|
{
|
||||||
|
int err, hw_buffer_size;
|
||||||
|
ssize_t hw_period_size;
|
||||||
|
snd_pcm_hw_params_t *hwparams;
|
||||||
|
snd_pcm_sw_params_t *swparams;
|
||||||
|
snd_pcm_uframes_t alsa_buffer_size, alsa_period_size;
|
||||||
|
|
||||||
|
inputf = snd_format_from_xmms( format, rate, channels );
|
||||||
|
convertb = xmms_convert_buffers_new();
|
||||||
|
snd_output_stdio_attach( &logs, stderr, 0 );
|
||||||
|
|
||||||
|
alsa_convert_func = NULL;
|
||||||
|
alsa_stereo_convert_func = NULL;
|
||||||
|
alsa_frequency_convert_func = NULL;
|
||||||
|
|
||||||
|
free( outputf );
|
||||||
|
outputf = snd_format_from_xmms( inputf->xmms_format, inputf->rate, inputf->channels );
|
||||||
|
|
||||||
|
qDebug() << "Opening device:" << device;
|
||||||
|
|
||||||
|
// FIXME: Can snd_pcm_open() return EAGAIN?
|
||||||
|
if ((err = snd_pcm_open( &alsa_pcm,
|
||||||
|
device.toAscii(),
|
||||||
|
SND_PCM_STREAM_PLAYBACK,
|
||||||
|
SND_PCM_NONBLOCK )) < 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to open pcm device (" << device << "):" << snd_strerror( -err );
|
||||||
|
alsa_pcm = NULL;
|
||||||
|
free( outputf );
|
||||||
|
outputf = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_pcm_info_t *info;
|
||||||
|
int alsa_card, alsa_device, alsa_subdevice;
|
||||||
|
|
||||||
|
snd_pcm_info_alloca( &info );
|
||||||
|
snd_pcm_info( alsa_pcm, info );
|
||||||
|
alsa_card = snd_pcm_info_get_card( info );
|
||||||
|
alsa_device = snd_pcm_info_get_device( info );
|
||||||
|
alsa_subdevice = snd_pcm_info_get_subdevice( info );
|
||||||
|
|
||||||
|
// qDebug() << "Card:" << alsa_card;
|
||||||
|
// qDebug() << "Device:" << alsa_device;
|
||||||
|
// qDebug() << "Subdevice:" << alsa_subdevice;
|
||||||
|
|
||||||
|
snd_pcm_hw_params_alloca( &hwparams );
|
||||||
|
|
||||||
|
if ( (err = snd_pcm_hw_params_any( alsa_pcm, hwparams ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "No configuration available for playback:"
|
||||||
|
<< snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_set_access( alsa_pcm, hwparams,
|
||||||
|
SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "Cannot set normal write mode:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_set_format( alsa_pcm, hwparams, outputf->format ) ) < 0 )
|
||||||
|
{
|
||||||
|
// Try if one of these format work (one of them should work
|
||||||
|
// on almost all soundcards)
|
||||||
|
|
||||||
|
snd_pcm_format_t formats[] = { SND_PCM_FORMAT_S16_LE,
|
||||||
|
SND_PCM_FORMAT_S16_BE,
|
||||||
|
SND_PCM_FORMAT_U8 };
|
||||||
|
|
||||||
|
uint i;
|
||||||
|
for ( i = 0; i < sizeof( formats ) / sizeof( formats[0] ); i++ )
|
||||||
|
{
|
||||||
|
if ( snd_pcm_hw_params_set_format( alsa_pcm, hwparams, formats[i] ) == 0 )
|
||||||
|
{
|
||||||
|
outputf->format = formats[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( outputf->format != inputf->format )
|
||||||
|
{
|
||||||
|
outputf->xmms_format = (AFormat)format_from_alsa( outputf->format );
|
||||||
|
|
||||||
|
qDebug() << "Converting format from" << inputf->xmms_format << "to" << outputf->xmms_format;
|
||||||
|
|
||||||
|
if ( outputf->xmms_format < 0 )
|
||||||
|
return -1;
|
||||||
|
alsa_convert_func = xmms_convert_get_func( outputf->xmms_format, inputf->xmms_format );
|
||||||
|
if ( alsa_convert_func == NULL )
|
||||||
|
{
|
||||||
|
qDebug() << "Format translation needed, but not available. Input:" << inputf->xmms_format << "; Output:" << outputf->xmms_format ;
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Sample format not available for playback:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_pcm_hw_params_set_channels_near( alsa_pcm, hwparams, &outputf->channels );
|
||||||
|
if ( outputf->channels != inputf->channels )
|
||||||
|
{
|
||||||
|
qDebug() << "Converting channels from" << inputf->channels << "to" << outputf->channels;
|
||||||
|
|
||||||
|
alsa_stereo_convert_func =
|
||||||
|
xmms_convert_get_channel_func( outputf->xmms_format,
|
||||||
|
outputf->channels,
|
||||||
|
inputf->channels );
|
||||||
|
if ( alsa_stereo_convert_func == NULL )
|
||||||
|
{
|
||||||
|
qDebug() << "No stereo conversion available. Format:" << outputf->xmms_format << "; Input Channels:" << inputf->channels << "; Output Channels:" << outputf->channels ;
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_pcm_hw_params_set_rate_near( alsa_pcm, hwparams, &outputf->rate, 0 );
|
||||||
|
if ( outputf->rate == 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "No usable samplerate available.";
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( outputf->rate != inputf->rate )
|
||||||
|
{
|
||||||
|
qDebug() << "Converting samplerate from" << inputf->rate << "to" << outputf->rate ;
|
||||||
|
if ( outputf->channels < 1 || outputf->channels > 2 )
|
||||||
|
{
|
||||||
|
qDebug() << "Unsupported number of channels:" << outputf->channels << "- Resample function not available" ;
|
||||||
|
alsa_frequency_convert_func = NULL;
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
alsa_frequency_convert_func =
|
||||||
|
xmms_convert_get_frequency_func( outputf->xmms_format,
|
||||||
|
outputf->channels );
|
||||||
|
if ( alsa_frequency_convert_func == NULL )
|
||||||
|
{
|
||||||
|
qDebug() << "Resample function not available. Format" << outputf->xmms_format ;
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
outputf->sample_bits = snd_pcm_format_physical_width( outputf->format );
|
||||||
|
outputf->bps = ( outputf->rate * outputf->sample_bits * outputf->channels ) >> 3;
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_set_period_size_near( alsa_pcm, hwparams,
|
||||||
|
&periodSize, NULL ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "Set period size failed:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_set_periods_near( alsa_pcm, hwparams,
|
||||||
|
&periodCount, 0 ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "Set period count failed:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( snd_pcm_hw_params( alsa_pcm, hwparams ) < 0 )
|
||||||
|
{
|
||||||
|
snd_pcm_hw_params_dump( hwparams, logs );
|
||||||
|
qDebug() << "Unable to install hw params";
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_get_buffer_size( hwparams, &alsa_buffer_size ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "snd_pcm_hw_params_get_buffer_size() failed:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_hw_params_get_period_size( hwparams, &alsa_period_size, 0 ) ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "snd_pcm_hw_params_get_period_size() failed:" << snd_strerror( -err );
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
snd_pcm_sw_params_alloca( &swparams );
|
||||||
|
snd_pcm_sw_params_current( alsa_pcm, swparams );
|
||||||
|
|
||||||
|
if ( ( err = snd_pcm_sw_params_set_start_threshold( alsa_pcm,
|
||||||
|
swparams, alsa_buffer_size - alsa_period_size ) < 0 ) )
|
||||||
|
qDebug() << "Setting start threshold failed:" << snd_strerror( -err );
|
||||||
|
if ( snd_pcm_sw_params( alsa_pcm, swparams ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "Unable to install sw params";
|
||||||
|
alsaClose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
snd_pcm_sw_params_dump( swparams, logs );
|
||||||
|
snd_pcm_dump( alsa_pcm, logs );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hw_period_size = snd_pcm_frames_to_bytes( alsa_pcm, alsa_period_size );
|
||||||
|
if ( inputf->bps != outputf->bps )
|
||||||
|
{
|
||||||
|
int align = ( inputf->sample_bits * inputf->channels ) / 8;
|
||||||
|
hw_period_size_in = ( (quint64)hw_period_size * inputf->bps +
|
||||||
|
outputf->bps/2 ) / outputf->bps;
|
||||||
|
hw_period_size_in -= hw_period_size_in % align;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hw_period_size_in = hw_period_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_buffer_size = snd_pcm_frames_to_bytes( alsa_pcm, alsa_buffer_size );
|
||||||
|
thread_buffer_size = minBufferCapacity * 4;
|
||||||
|
if ( thread_buffer_size < hw_buffer_size )
|
||||||
|
thread_buffer_size = hw_buffer_size * 2;
|
||||||
|
if ( thread_buffer_size < 8192 )
|
||||||
|
thread_buffer_size = 8192;
|
||||||
|
thread_buffer_size += hw_buffer_size;
|
||||||
|
thread_buffer_size -= thread_buffer_size % hw_period_size;
|
||||||
|
|
||||||
|
thread_buffer = (char*)calloc(thread_buffer_size, sizeof(char));
|
||||||
|
|
||||||
|
// qDebug() << "Device setup: period size:" << hw_period_size;
|
||||||
|
// qDebug() << "Device setup: hw_period_size_in:" << hw_period_size_in;
|
||||||
|
// qDebug() << "Device setup: hw_buffer_size:" << hw_buffer_size;
|
||||||
|
// qDebug() << "Device setup: thread_buffer_size:" << thread_buffer_size;
|
||||||
|
// qDebug() << "bits per sample:" << snd_pcm_format_physical_width( outputf->format )
|
||||||
|
// << "frame size:" << snd_pcm_frames_to_bytes( alsa_pcm, 1 )
|
||||||
|
// << "Bps:" << outputf->bps;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::startPlayback()
|
||||||
|
{
|
||||||
|
int pthreadError = 0;
|
||||||
|
|
||||||
|
// We should double check this here. AlsaPlayback::initAudio
|
||||||
|
// isn't having its emitted error caught.
|
||||||
|
// So double check here to avoid a potential assert.
|
||||||
|
if ( !alsa_pcm )
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
going = true;
|
||||||
|
|
||||||
|
// qDebug() << "Starting thread";
|
||||||
|
AlsaAudio* aaThread = new AlsaAudio();
|
||||||
|
pthreadError = pthread_create( &audio_thread, NULL, &alsa_loop, (void*)aaThread );
|
||||||
|
|
||||||
|
return pthreadError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::clearBuffer( void )
|
||||||
|
{
|
||||||
|
wr_index = rd_index = pcmCounter = 0;
|
||||||
|
if ( thread_buffer )
|
||||||
|
memset( thread_buffer, 0, thread_buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
Play Interface
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::alsaWrite( const QByteArray& input )
|
||||||
|
{
|
||||||
|
int cnt;
|
||||||
|
const char *src = input.data();
|
||||||
|
int length = input.size();
|
||||||
|
//qDebug() << "alsaWrite length:" << length;
|
||||||
|
|
||||||
|
while ( length > 0 )
|
||||||
|
{
|
||||||
|
int wr;
|
||||||
|
cnt = qMin(length, thread_buffer_size - wr_index);
|
||||||
|
memcpy(thread_buffer + wr_index, src, cnt);
|
||||||
|
wr = (wr_index + cnt) % thread_buffer_size;
|
||||||
|
wr_index = wr;
|
||||||
|
length -= cnt;
|
||||||
|
src += cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::get_thread_buffer_filled() const
|
||||||
|
{
|
||||||
|
if ( wr_index >= rd_index )
|
||||||
|
{
|
||||||
|
return wr_index - rd_index;
|
||||||
|
}
|
||||||
|
return ( thread_buffer_size - ( rd_index - wr_index ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// HACK: the buffer may have data, but not enough to send to the card. In that
|
||||||
|
// case we tell alsaplayback that we don't have any. This may chop off some
|
||||||
|
// data, but only at the natural end of a track. On my machine, this is at
|
||||||
|
// most 3759 bytes. That's less than 0.022 sec. It beats padding the buffer
|
||||||
|
// with 0's if the stream fails mid track. No stutter this way.
|
||||||
|
int
|
||||||
|
AlsaAudio::hasData()
|
||||||
|
{
|
||||||
|
int tempSize = get_thread_buffer_filled();
|
||||||
|
if ( tempSize < hw_period_size_in )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return tempSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::alsa_free() const
|
||||||
|
{
|
||||||
|
//qDebug() << "alsa_free:" << thread_buffer_size - get_thread_buffer_filled() - 1;
|
||||||
|
return thread_buffer_size - get_thread_buffer_filled() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::setVolume ( float v )
|
||||||
|
{
|
||||||
|
volume = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::stopPlayback()
|
||||||
|
{
|
||||||
|
if (going)
|
||||||
|
{
|
||||||
|
// Q_DEBUG_BLOCK;
|
||||||
|
|
||||||
|
going = false;
|
||||||
|
|
||||||
|
pthread_join( audio_thread, NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::alsaClose()
|
||||||
|
{
|
||||||
|
// Q_DEBUG_BLOCK;
|
||||||
|
|
||||||
|
alsa_close_pcm();
|
||||||
|
|
||||||
|
xmms_convert_buffers_destroy( convertb );
|
||||||
|
convertb = NULL;
|
||||||
|
|
||||||
|
if ( thread_buffer )
|
||||||
|
{
|
||||||
|
free(thread_buffer);
|
||||||
|
thread_buffer = NULL;
|
||||||
|
}
|
||||||
|
if ( inputf )
|
||||||
|
{
|
||||||
|
free( inputf );
|
||||||
|
inputf = NULL;
|
||||||
|
}
|
||||||
|
if (outputf )
|
||||||
|
{
|
||||||
|
free( outputf );
|
||||||
|
outputf = NULL;
|
||||||
|
}
|
||||||
|
if ( logs )
|
||||||
|
{
|
||||||
|
snd_output_close( logs );
|
||||||
|
logs = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
Play Thread
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
void*
|
||||||
|
AlsaAudio::alsa_loop( void* pthis )
|
||||||
|
{
|
||||||
|
AlsaAudio* aaThread = (AlsaAudio*)pthis;
|
||||||
|
aaThread->run();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::run()
|
||||||
|
{
|
||||||
|
int npfds = snd_pcm_poll_descriptors_count( alsa_pcm );
|
||||||
|
int wr = 0;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if ( npfds <= 0 )
|
||||||
|
goto _error;
|
||||||
|
|
||||||
|
err = snd_pcm_prepare( alsa_pcm );
|
||||||
|
if ( err < 0 )
|
||||||
|
qDebug() << "snd_pcm_prepare error:" << snd_strerror( err );
|
||||||
|
|
||||||
|
while ( going && alsa_pcm )
|
||||||
|
{
|
||||||
|
if ( !paused && get_thread_buffer_filled() >= hw_period_size_in )
|
||||||
|
{
|
||||||
|
wr = snd_pcm_wait( alsa_pcm, 10 );
|
||||||
|
|
||||||
|
if ( wr > 0 )
|
||||||
|
{
|
||||||
|
alsa_write_out_thread_data();
|
||||||
|
}
|
||||||
|
else if ( wr < 0 )
|
||||||
|
{
|
||||||
|
alsa_handle_error( wr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct timespec req;
|
||||||
|
req.tv_sec = 0;
|
||||||
|
req.tv_nsec = 10000000; //0.1 seconds
|
||||||
|
nanosleep( &req, NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_error:
|
||||||
|
err = snd_pcm_drop( alsa_pcm );
|
||||||
|
if ( err < 0 )
|
||||||
|
qDebug() << "snd_pcm_drop error:" << snd_strerror( err );
|
||||||
|
wr_index = rd_index = 0;
|
||||||
|
memset( thread_buffer, 0, thread_buffer_size );
|
||||||
|
|
||||||
|
// qDebug() << "Exiting thread";
|
||||||
|
|
||||||
|
pthread_exit( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* transfer audio data from thread buffer to h/w */
|
||||||
|
void
|
||||||
|
AlsaAudio::alsa_write_out_thread_data( void )
|
||||||
|
{
|
||||||
|
ssize_t length;
|
||||||
|
int cnt;
|
||||||
|
length = qMin( hw_period_size_in, ssize_t(get_thread_buffer_filled()) );
|
||||||
|
length = qMin( length, snd_pcm_frames_to_bytes( alsa_pcm, alsa_get_avail() ) );
|
||||||
|
|
||||||
|
while (length > 0)
|
||||||
|
{
|
||||||
|
int rd;
|
||||||
|
cnt = qMin(int(length), thread_buffer_size - rd_index);
|
||||||
|
alsa_do_write( thread_buffer + rd_index, cnt);
|
||||||
|
rd = (rd_index + cnt) % thread_buffer_size;
|
||||||
|
rd_index = rd;
|
||||||
|
length -= cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* update and get the available space on h/w buffer (in frames) */
|
||||||
|
snd_pcm_sframes_t
|
||||||
|
AlsaAudio::alsa_get_avail( void )
|
||||||
|
{
|
||||||
|
snd_pcm_sframes_t ret;
|
||||||
|
|
||||||
|
if ( alsa_pcm == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ( ( ret = snd_pcm_avail_update( alsa_pcm ) ) < 0 )
|
||||||
|
{
|
||||||
|
ret = alsa_handle_error( ret );
|
||||||
|
if ( ret < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "alsa_get_avail(): snd_pcm_avail_update() failed:" << snd_strerror( -ret );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* transfer data to audio h/w; length is given in bytes
|
||||||
|
*
|
||||||
|
* data can be modified via rate conversion or
|
||||||
|
* software volume before passed to audio h/w
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
AlsaAudio::alsa_do_write( void* data, ssize_t length )
|
||||||
|
{
|
||||||
|
if ( alsa_convert_func != NULL )
|
||||||
|
length = alsa_convert_func( convertb, &data, length );
|
||||||
|
if ( alsa_stereo_convert_func != NULL )
|
||||||
|
length = alsa_stereo_convert_func( convertb, &data, length );
|
||||||
|
if ( alsa_frequency_convert_func != NULL )
|
||||||
|
{
|
||||||
|
length = alsa_frequency_convert_func( convertb, &data, length,
|
||||||
|
inputf->rate,
|
||||||
|
outputf->rate );
|
||||||
|
}
|
||||||
|
|
||||||
|
volume_adjust( data, length, outputf->xmms_format );
|
||||||
|
|
||||||
|
alsa_write_audio( (char*)data, length );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define VOLUME_ADJUST( type, endian ) \
|
||||||
|
do { \
|
||||||
|
type *ptr = (type*)data; \
|
||||||
|
for ( i = 0; i < length; i += 2 ) \
|
||||||
|
{ \
|
||||||
|
*ptr = qTo##endian( (type)( qFrom##endian( *ptr ) * volume ) ); \
|
||||||
|
ptr++; \
|
||||||
|
} \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
|
#define VOLUME_ADJUST8( type ) \
|
||||||
|
do { \
|
||||||
|
type *ptr = (type*)data; \
|
||||||
|
for ( i = 0; i < length; i++ ) \
|
||||||
|
{ \
|
||||||
|
*ptr = (type)( *ptr * volume ); \
|
||||||
|
ptr++; \
|
||||||
|
} \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaAudio::volume_adjust( void* data, ssize_t length, AFormat fmt )
|
||||||
|
{
|
||||||
|
ssize_t i;
|
||||||
|
if ( volume == 1.0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch ( fmt )
|
||||||
|
{
|
||||||
|
case FMT_S16_LE:
|
||||||
|
VOLUME_ADJUST( qint16, LittleEndian );
|
||||||
|
break;
|
||||||
|
case FMT_U16_LE:
|
||||||
|
VOLUME_ADJUST( quint16, LittleEndian );
|
||||||
|
break;
|
||||||
|
case FMT_S16_BE:
|
||||||
|
VOLUME_ADJUST( qint16, BigEndian );
|
||||||
|
break;
|
||||||
|
case FMT_U16_BE:
|
||||||
|
VOLUME_ADJUST( quint16, BigEndian );
|
||||||
|
break;
|
||||||
|
case FMT_S8:
|
||||||
|
VOLUME_ADJUST8( qint8 );
|
||||||
|
break;
|
||||||
|
case FMT_U8:
|
||||||
|
VOLUME_ADJUST8( quint8 );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug() << __PRETTY_FUNCTION__ << "unhandled format:" << fmt ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* transfer data to audio h/w via normal write */
|
||||||
|
void
|
||||||
|
AlsaAudio::alsa_write_audio( char *data, ssize_t length )
|
||||||
|
{
|
||||||
|
snd_pcm_sframes_t written_frames;
|
||||||
|
|
||||||
|
while ( length > 0 )
|
||||||
|
{
|
||||||
|
snd_pcm_sframes_t frames = snd_pcm_bytes_to_frames( alsa_pcm, length );
|
||||||
|
written_frames = snd_pcm_writei( alsa_pcm, data, frames );
|
||||||
|
|
||||||
|
if ( written_frames > 0 )
|
||||||
|
{
|
||||||
|
ssize_t written = snd_pcm_frames_to_bytes( alsa_pcm, written_frames );
|
||||||
|
pcmCounter += written;
|
||||||
|
|
||||||
|
length -= written;
|
||||||
|
data += written;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int err = alsa_handle_error( (int)written_frames );
|
||||||
|
if ( err < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << __PRETTY_FUNCTION__ << "write error:" << snd_strerror( -err );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* handle generic errors */
|
||||||
|
int
|
||||||
|
AlsaAudio::alsa_handle_error( int err )
|
||||||
|
{
|
||||||
|
switch ( err )
|
||||||
|
{
|
||||||
|
case -EPIPE:
|
||||||
|
return xrun_recover();
|
||||||
|
case -ESTRPIPE:
|
||||||
|
return suspend_recover();
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* close PCM and release associated resources */
|
||||||
|
void
|
||||||
|
AlsaAudio::alsa_close_pcm( void )
|
||||||
|
{
|
||||||
|
if ( alsa_pcm )
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
snd_pcm_drop( alsa_pcm );
|
||||||
|
if ( ( err = snd_pcm_close( alsa_pcm ) ) < 0 )
|
||||||
|
qDebug() << "alsa_close_pcm() failed:" << snd_strerror( -err );
|
||||||
|
alsa_pcm = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::format_from_alsa( snd_pcm_format_t fmt )
|
||||||
|
{
|
||||||
|
uint i;
|
||||||
|
for ( i = 0; i < sizeof( format_table ) / sizeof( format_table[0] ); i++ )
|
||||||
|
if ( format_table[i].alsa == fmt )
|
||||||
|
return format_table[i].xmms;
|
||||||
|
qDebug() << "Unsupported format:" << snd_pcm_format_name( fmt );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct snd_format*
|
||||||
|
AlsaAudio::snd_format_from_xmms( AFormat fmt, unsigned int rate, unsigned int channels )
|
||||||
|
{
|
||||||
|
struct snd_format *f = (struct snd_format*)malloc( sizeof( struct snd_format ) );
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
f->xmms_format = fmt;
|
||||||
|
f->format = SND_PCM_FORMAT_UNKNOWN;
|
||||||
|
|
||||||
|
for ( i = 0; i < sizeof( format_table ) / sizeof( format_table[0] ); i++ )
|
||||||
|
{
|
||||||
|
if ( format_table[i].xmms == fmt )
|
||||||
|
{
|
||||||
|
f->format = format_table[i].alsa;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get rid of _NE */
|
||||||
|
for ( i = 0; i < sizeof( format_table ) / sizeof( format_table[0] ); i++ )
|
||||||
|
{
|
||||||
|
if ( format_table[i].alsa == f->format )
|
||||||
|
{
|
||||||
|
f->xmms_format = format_table[i].xmms;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f->rate = rate;
|
||||||
|
f->channels = channels;
|
||||||
|
f->sample_bits = snd_pcm_format_physical_width( f->format );
|
||||||
|
f->bps = ( rate * f->sample_bits * channels ) >> 3;
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::xrun_recover( void )
|
||||||
|
{
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
snd_pcm_status_t *alsa_status;
|
||||||
|
snd_pcm_status_alloca( &alsa_status );
|
||||||
|
if ( snd_pcm_status( alsa_pcm, alsa_status ) < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "AlsaAudio::xrun_recover(): snd_pcm_status() failed";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snd_pcm_status_dump( alsa_status, logs );
|
||||||
|
qDebug() << "Status:\n" << logs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return snd_pcm_prepare( alsa_pcm );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaAudio::suspend_recover( void )
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
while ( ( err = snd_pcm_resume( alsa_pcm ) ) == -EAGAIN )
|
||||||
|
/* wait until suspend flag is released */
|
||||||
|
sleep( 1 );
|
||||||
|
if ( err < 0 )
|
||||||
|
{
|
||||||
|
qDebug() << "alsa_handle_error(): snd_pcm_resume() failed." ;
|
||||||
|
return snd_pcm_prepare( alsa_pcm );
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
AlsaAudio::timeElapsed()
|
||||||
|
{
|
||||||
|
return pcmCounter / outputf->bps;
|
||||||
|
}
|
136
alsa-playback/alsaaudio.h
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007 by John Stamp, <jstamp@users.sourceforge.net> *
|
||||||
|
* Copyright (C) 2007 by Max Howell, Last.fm Ltd. *
|
||||||
|
* Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ALSA_AUDIO_H
|
||||||
|
#define ALSA_AUDIO_H
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <alsa/asoundlib.h>
|
||||||
|
#include "xconvert.h"
|
||||||
|
|
||||||
|
struct AlsaDeviceInfo
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
QString device;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct snd_format
|
||||||
|
{
|
||||||
|
unsigned int rate;
|
||||||
|
unsigned int channels;
|
||||||
|
snd_pcm_format_t format;
|
||||||
|
AFormat xmms_format;
|
||||||
|
int sample_bits;
|
||||||
|
int bps;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
AFormat xmms;
|
||||||
|
snd_pcm_format_t alsa;
|
||||||
|
}
|
||||||
|
|
||||||
|
format_table[] = { { FMT_S16_LE, SND_PCM_FORMAT_S16_LE },
|
||||||
|
{ FMT_S16_BE, SND_PCM_FORMAT_S16_BE },
|
||||||
|
{ FMT_S16_NE, SND_PCM_FORMAT_S16 },
|
||||||
|
{ FMT_U16_LE, SND_PCM_FORMAT_U16_LE },
|
||||||
|
{ FMT_U16_BE, SND_PCM_FORMAT_U16_BE },
|
||||||
|
{ FMT_U16_NE, SND_PCM_FORMAT_U16 },
|
||||||
|
{ FMT_U8, SND_PCM_FORMAT_U8 },
|
||||||
|
{ FMT_S8, SND_PCM_FORMAT_S8 }, };
|
||||||
|
|
||||||
|
class AlsaAudio
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlsaAudio();
|
||||||
|
~AlsaAudio();
|
||||||
|
|
||||||
|
int getCards();
|
||||||
|
AlsaDeviceInfo getDeviceInfo( int device );
|
||||||
|
|
||||||
|
bool alsaOpen( QString device, AFormat format, unsigned int rate,
|
||||||
|
unsigned int channels, snd_pcm_uframes_t periodSize,
|
||||||
|
unsigned int periodCount, int minBufferCapacity );
|
||||||
|
|
||||||
|
int startPlayback();
|
||||||
|
void stopPlayback();
|
||||||
|
|
||||||
|
void alsaWrite( const QByteArray& inputData );
|
||||||
|
void alsaClose();
|
||||||
|
|
||||||
|
void setVolume( float vol );
|
||||||
|
void setPaused( bool enabled ) { paused = enabled; }
|
||||||
|
|
||||||
|
unsigned int timeElapsed();
|
||||||
|
|
||||||
|
int hasData();
|
||||||
|
int get_thread_buffer_filled() const;
|
||||||
|
int alsa_free() const;
|
||||||
|
void clearBuffer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<AlsaDeviceInfo> m_devices;
|
||||||
|
|
||||||
|
// The following static variables are configured in either
|
||||||
|
// alsaOpen or alsaSetup and used later in the audio thread
|
||||||
|
static ssize_t hw_period_size_in;
|
||||||
|
static snd_output_t *logs;
|
||||||
|
static bool going;
|
||||||
|
static snd_pcm_t *alsa_pcm;
|
||||||
|
static snd_format* inputf;
|
||||||
|
static snd_format* outputf;
|
||||||
|
static float volume;
|
||||||
|
static bool paused;
|
||||||
|
static convert_func_t alsa_convert_func;
|
||||||
|
static convert_channel_func_t alsa_stereo_convert_func;
|
||||||
|
static convert_freq_func_t alsa_frequency_convert_func;
|
||||||
|
static xmms_convert_buffers *convertb;
|
||||||
|
static pthread_t audio_thread;
|
||||||
|
static unsigned int pcmCounter;
|
||||||
|
|
||||||
|
void getDevicesForCard( int card );
|
||||||
|
|
||||||
|
static void* alsa_loop( void* );
|
||||||
|
void run();
|
||||||
|
void alsa_write_out_thread_data();
|
||||||
|
void alsa_do_write( void* data, ssize_t length );
|
||||||
|
void volume_adjust( void* data, ssize_t length, AFormat fmt );
|
||||||
|
void alsa_write_audio( char *data, ssize_t length );
|
||||||
|
//int get_thread_buffer_filled() const;
|
||||||
|
|
||||||
|
static char* thread_buffer;
|
||||||
|
static int thread_buffer_size;
|
||||||
|
static int rd_index, wr_index;
|
||||||
|
|
||||||
|
snd_pcm_sframes_t alsa_get_avail( void );
|
||||||
|
int alsa_handle_error( int err );
|
||||||
|
int xrun_recover();
|
||||||
|
int suspend_recover();
|
||||||
|
int format_from_alsa( snd_pcm_format_t fmt );
|
||||||
|
snd_format* snd_format_from_xmms( AFormat fmt, unsigned int rate, unsigned int channels );
|
||||||
|
|
||||||
|
void alsa_close_pcm( void );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
217
alsa-playback/alsaplayback.cpp
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2005 - 2010 by *
|
||||||
|
* Christian Muehlhaeuser <muesli@gmail.com> *
|
||||||
|
* Erik Jaelevik, Last.fm Ltd <erik@last.fm> *
|
||||||
|
* Max Howell, Last.fm Ltd <max@last.fm> *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "alsaaudio.h"
|
||||||
|
#include "alsaplayback.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
|
AlsaPlayback::AlsaPlayback()
|
||||||
|
: m_audio( 0 )
|
||||||
|
, m_paused( false )
|
||||||
|
, m_playing( false )
|
||||||
|
, m_volume( 0.75 )
|
||||||
|
, m_deviceNum( 0 )
|
||||||
|
{
|
||||||
|
setBufferCapacity( 32768 * 4 ); //FIXME: const value
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AlsaPlayback::~AlsaPlayback()
|
||||||
|
{
|
||||||
|
delete m_audio;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
AlsaPlayback::haveData()
|
||||||
|
{
|
||||||
|
return ( m_audio->hasData() > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
AlsaPlayback::needData()
|
||||||
|
{
|
||||||
|
return ( m_audio->get_thread_buffer_filled() < m_bufferCapacity );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::setBufferCapacity( int size )
|
||||||
|
{
|
||||||
|
m_bufferCapacity = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
AlsaPlayback::bufferSize()
|
||||||
|
{
|
||||||
|
return m_audio->get_thread_buffer_filled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
AlsaPlayback::volume()
|
||||||
|
{
|
||||||
|
return m_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::setVolume( int volume )
|
||||||
|
{
|
||||||
|
m_volume = (float)volume / 100.0;
|
||||||
|
m_audio->setVolume( m_volume );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::triggerTimers()
|
||||||
|
{
|
||||||
|
if ( m_audio )
|
||||||
|
emit timeElapsed( m_audio->timeElapsed() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
AlsaPlayback::soundSystems()
|
||||||
|
{
|
||||||
|
return QStringList() << "Alsa";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
AlsaPlayback::devices()
|
||||||
|
{
|
||||||
|
// Q_DEBUG_BLOCK << "Querying audio devices";
|
||||||
|
|
||||||
|
QStringList devices;
|
||||||
|
for (int i = 0, n = m_audio->getCards(); i < n; i++)
|
||||||
|
devices << m_audio->getDeviceInfo( i ).name;
|
||||||
|
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
AlsaPlayback::startPlayback()
|
||||||
|
{
|
||||||
|
if ( !m_audio )
|
||||||
|
{
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_audio->startPlayback() )
|
||||||
|
{
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_playing = true;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::stopPlayback()
|
||||||
|
{
|
||||||
|
m_audio->stopPlayback();
|
||||||
|
m_paused = false;
|
||||||
|
m_playing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::initAudio( long sampleRate, int channels )
|
||||||
|
{
|
||||||
|
int periodSize = 1024; // According to mplayer, these two are good defaults.
|
||||||
|
int periodCount = 16; // They create a buffer size of 16384 frames.
|
||||||
|
QString cardDevice;
|
||||||
|
|
||||||
|
delete m_audio;
|
||||||
|
m_audio = new AlsaAudio;
|
||||||
|
m_audio->clearBuffer();
|
||||||
|
|
||||||
|
cardDevice = internalSoundCardID( m_deviceNum );
|
||||||
|
|
||||||
|
// We assume host byte order
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
if ( !m_audio->alsaOpen( cardDevice, FMT_S16_BE, sampleRate, channels, periodSize, periodCount, m_bufferCapacity ) )
|
||||||
|
#else
|
||||||
|
if ( !m_audio->alsaOpen( cardDevice, FMT_S16_LE, sampleRate, channels, periodSize, periodCount, m_bufferCapacity ) )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::processData( const QByteArray &buffer )
|
||||||
|
{
|
||||||
|
m_audio->alsaWrite( buffer );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::clearBuffers()
|
||||||
|
{
|
||||||
|
m_audio->clearBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
AlsaPlayback::internalSoundCardID( int settingsID )
|
||||||
|
{
|
||||||
|
int cards = m_audio->getCards();
|
||||||
|
|
||||||
|
if ( settingsID < cards )
|
||||||
|
return m_audio->getDeviceInfo( settingsID ).device;
|
||||||
|
else
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::pause()
|
||||||
|
{
|
||||||
|
m_paused = true;
|
||||||
|
|
||||||
|
if ( m_audio )
|
||||||
|
{
|
||||||
|
m_audio->setPaused( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlsaPlayback::resume()
|
||||||
|
{
|
||||||
|
m_paused = false;
|
||||||
|
|
||||||
|
if ( m_audio )
|
||||||
|
m_audio->setPaused( false );
|
||||||
|
}
|
80
alsa-playback/alsaplayback.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2005 - 2010 by *
|
||||||
|
* Christian Muehlhaeuser <muesli@gmail.com> *
|
||||||
|
* Erik Jaelevik, Last.fm Ltd <erik@last.fm> *
|
||||||
|
* Max Howell, Last.fm Ltd <max@last.fm> *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ALSAPLAYBACK_H
|
||||||
|
#define ALSAPLAYBACK_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class AlsaPlayback : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AlsaPlayback();
|
||||||
|
~AlsaPlayback();
|
||||||
|
|
||||||
|
virtual void initAudio( long sampleRate, int channels );
|
||||||
|
|
||||||
|
virtual float volume();
|
||||||
|
virtual bool isPaused() { return m_paused; }
|
||||||
|
virtual bool isPlaying() { return m_playing; }
|
||||||
|
|
||||||
|
virtual bool haveData();
|
||||||
|
virtual bool needData();
|
||||||
|
virtual void processData( const QByteArray& );
|
||||||
|
|
||||||
|
virtual void setBufferCapacity( int size );
|
||||||
|
virtual int bufferSize();
|
||||||
|
|
||||||
|
virtual QStringList soundSystems();
|
||||||
|
virtual QStringList devices();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void clearBuffers();
|
||||||
|
|
||||||
|
virtual bool startPlayback();
|
||||||
|
virtual void stopPlayback();
|
||||||
|
|
||||||
|
virtual void pause();
|
||||||
|
virtual void resume();
|
||||||
|
|
||||||
|
virtual void setVolume( int volume );
|
||||||
|
|
||||||
|
virtual void triggerTimers();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void timeElapsed( unsigned int seconds );
|
||||||
|
|
||||||
|
private:
|
||||||
|
class AlsaAudio *m_audio;
|
||||||
|
int m_bufferCapacity;
|
||||||
|
|
||||||
|
bool m_paused;
|
||||||
|
bool m_playing;
|
||||||
|
float m_volume;
|
||||||
|
int m_deviceNum;
|
||||||
|
|
||||||
|
QString internalSoundCardID( int settingsID );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
771
alsa-playback/xconvert.c
Normal file
@@ -0,0 +1,771 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2001-2003 Haavard Kvaalen <havardk@xmms.org>
|
||||||
|
*
|
||||||
|
* Licensed under GNU LGPL version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "xconvert.h"
|
||||||
|
|
||||||
|
// These are adapted from defines in gtypes.h and glibconfig.h
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE ( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE ( !FALSE )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define GUINT16_SWAP_LE_BE( val ) \
|
||||||
|
( ( uint16_t ) \
|
||||||
|
( \
|
||||||
|
( uint16_t ) ( ( uint16_t ) ( val ) >> 8 ) | \
|
||||||
|
( uint16_t ) ( ( uint16_t ) ( val ) << 8 ) \
|
||||||
|
) \
|
||||||
|
)
|
||||||
|
|
||||||
|
# define GINT16_SWAP_LE_BE( val ) ( ( int16_t ) GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
# define IS_BIG_ENDIAN TRUE
|
||||||
|
|
||||||
|
# define GINT16_TO_BE( val ) ( ( int16_t ) ( val ) )
|
||||||
|
# define GINT16_FROM_BE( val ) ( ( int16_t ) ( val ) )
|
||||||
|
# define GUINT16_TO_BE( val ) ( ( uint16_t ) ( val ) )
|
||||||
|
# define GUINT16_FROM_BE( val ) ( ( uint16_t ) ( val ) )
|
||||||
|
|
||||||
|
# define GUINT16_TO_LE( val ) ( GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GUINT16_FROM_LE( val ) ( GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GINT16_TO_LE( val ) ( ( int16_t ) GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GINT16_FROM_LE( val ) ( ( int16_t ) GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define IS_BIG_ENDIAN FALSE
|
||||||
|
|
||||||
|
# define GINT16_TO_LE( val ) ( ( int16_t ) ( val ) )
|
||||||
|
# define GINT16_FROM_LE( val ) ( ( int16_t ) ( val ) )
|
||||||
|
# define GUINT16_TO_LE( val ) ( ( uint16_t ) ( val ) )
|
||||||
|
# define GUINT16_FROM_LE( val ) ( ( uint16_t ) ( val ) )
|
||||||
|
|
||||||
|
# define GUINT16_TO_BE( val ) ( GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GUINT16_FROM_BE( val ) ( GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GINT16_TO_BE( val ) ( ( int16_t ) GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
# define GINT16_FROM_BE( val ) ( ( int16_t ) GUINT16_SWAP_LE_BE ( val ) )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
struct buffer {
|
||||||
|
void *buffer;
|
||||||
|
uint size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xmms_convert_buffers {
|
||||||
|
struct buffer format_buffer, stereo_buffer, freq_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xmms_convert_buffers* xmms_convert_buffers_new( void )
|
||||||
|
{
|
||||||
|
return calloc( 1, sizeof( struct xmms_convert_buffers ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* convert_get_buffer( struct buffer *buffer, size_t size )
|
||||||
|
{
|
||||||
|
if ( size > 0 && size <= buffer->size )
|
||||||
|
return buffer->buffer;
|
||||||
|
|
||||||
|
buffer->size = size;
|
||||||
|
buffer->buffer = realloc( buffer->buffer, size );
|
||||||
|
return buffer->buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmms_convert_buffers_free( struct xmms_convert_buffers* buf )
|
||||||
|
{
|
||||||
|
convert_get_buffer( &buf->format_buffer, 0 );
|
||||||
|
convert_get_buffer( &buf->stereo_buffer, 0 );
|
||||||
|
convert_get_buffer( &buf->freq_buffer, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmms_convert_buffers_destroy( struct xmms_convert_buffers* buf )
|
||||||
|
{
|
||||||
|
if ( !buf )
|
||||||
|
return;
|
||||||
|
xmms_convert_buffers_free( buf );
|
||||||
|
free( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_swap_endian( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint16_t *ptr = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length; i += 2, ptr++ )
|
||||||
|
*ptr = GUINT16_SWAP_LE_BE( *ptr );
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_swap_sign_and_endian_to_native( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint16_t *ptr = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length; i += 2, ptr++ )
|
||||||
|
*ptr = GUINT16_SWAP_LE_BE( *ptr ) ^ 1 << 15;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_swap_sign_and_endian_to_alien( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint16_t *ptr = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length; i += 2, ptr++ )
|
||||||
|
*ptr = GUINT16_SWAP_LE_BE( *ptr ^ 1 << 15 );
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_swap_sign16( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int16_t *ptr = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length; i += 2, ptr++ )
|
||||||
|
*ptr ^= 1 << 15;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_swap_sign8( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *ptr = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
*ptr++ ^= 1 << 7;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_8_native_endian( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *output = *data;
|
||||||
|
int16_t *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
*output++ = *input++ >> 8;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_8_native_endian_swap_sign( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *output = *data;
|
||||||
|
int16_t *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
*output++ = ( *input++ >> 8 ) ^ ( 1 << 7 );
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int convert_to_8_alien_endian( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *output = *data;
|
||||||
|
int16_t *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
*output++ = *input++ & 0xff;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_8_alien_endian_swap_sign( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *output = *data;
|
||||||
|
int16_t *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
*output++ = ( *input++ & 0xff ) ^ ( 1 << 7 );
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_16_native_endian( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint8_t *input = *data;
|
||||||
|
uint16_t *output;
|
||||||
|
int i;
|
||||||
|
*data = convert_get_buffer( &buf->format_buffer, length * 2 );
|
||||||
|
output = *data;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
*output++ = *input++ << 8;
|
||||||
|
|
||||||
|
return i * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_16_native_endian_swap_sign( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint8_t *input = *data;
|
||||||
|
uint16_t *output;
|
||||||
|
int i;
|
||||||
|
*data = convert_get_buffer( &buf->format_buffer, length * 2 );
|
||||||
|
output = *data;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
*output++ = ( *input++ << 8 ) ^ ( 1 << 15 );
|
||||||
|
|
||||||
|
return i * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int convert_to_16_alien_endian( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint8_t *input = *data;
|
||||||
|
uint16_t *output;
|
||||||
|
int i;
|
||||||
|
*data = convert_get_buffer( &buf->format_buffer, length * 2 );
|
||||||
|
output = *data;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
*output++ = *input++;
|
||||||
|
|
||||||
|
return i * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_to_16_alien_endian_swap_sign( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint8_t *input = *data;
|
||||||
|
uint16_t *output;
|
||||||
|
int i;
|
||||||
|
*data = convert_get_buffer( &buf->format_buffer, length * 2 );
|
||||||
|
output = *data;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
*output++ = *input++ ^ ( 1 << 7 );
|
||||||
|
|
||||||
|
return i * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AFormat unnativize( AFormat fmt )
|
||||||
|
{
|
||||||
|
if ( fmt == FMT_S16_NE )
|
||||||
|
{
|
||||||
|
if ( IS_BIG_ENDIAN )
|
||||||
|
return FMT_S16_BE;
|
||||||
|
else
|
||||||
|
return FMT_S16_LE;
|
||||||
|
}
|
||||||
|
if ( fmt == FMT_U16_NE )
|
||||||
|
{
|
||||||
|
if ( IS_BIG_ENDIAN )
|
||||||
|
return FMT_U16_BE;
|
||||||
|
else
|
||||||
|
return FMT_U16_LE;
|
||||||
|
}
|
||||||
|
return fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
convert_func_t xmms_convert_get_func( AFormat output, AFormat input )
|
||||||
|
{
|
||||||
|
output = unnativize( output );
|
||||||
|
input = unnativize( input );
|
||||||
|
|
||||||
|
if ( output == input )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( ( output == FMT_U16_BE && input == FMT_U16_LE ) ||
|
||||||
|
( output == FMT_U16_LE && input == FMT_U16_BE ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_S16_BE ) )
|
||||||
|
return convert_swap_endian;
|
||||||
|
|
||||||
|
if ( ( output == FMT_U16_BE && input == FMT_S16_BE ) ||
|
||||||
|
( output == FMT_U16_LE && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_U16_BE ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_U16_LE ) )
|
||||||
|
return convert_swap_sign16;
|
||||||
|
|
||||||
|
if ( ( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_U16_LE ) ) ) ||
|
||||||
|
( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_S16_BE ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_U16_BE ) ) ) )
|
||||||
|
return convert_swap_sign_and_endian_to_native;
|
||||||
|
|
||||||
|
if ( ( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_U16_LE ) ) ) ||
|
||||||
|
( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_S16_BE ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_U16_BE ) ) ) )
|
||||||
|
return convert_swap_sign_and_endian_to_alien;
|
||||||
|
|
||||||
|
if ( ( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_U16_BE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_S16_BE ) ) ) ||
|
||||||
|
( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_U16_LE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_S16_LE ) ) ) )
|
||||||
|
return convert_to_8_native_endian;
|
||||||
|
|
||||||
|
if ( ( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_S16_BE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_U16_BE ) ) ) ||
|
||||||
|
( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_U16_LE ) ) ) )
|
||||||
|
return convert_to_8_native_endian_swap_sign;
|
||||||
|
|
||||||
|
if ( ( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_U16_BE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_S16_BE ) ) ) ||
|
||||||
|
( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_U16_LE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_S16_LE ) ) ) )
|
||||||
|
return convert_to_8_alien_endian;
|
||||||
|
|
||||||
|
if ( ( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_S16_BE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_U16_BE ) ) ) ||
|
||||||
|
( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U8 && input == FMT_S16_LE ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_U16_LE ) ) ) )
|
||||||
|
return convert_to_8_alien_endian_swap_sign;
|
||||||
|
|
||||||
|
if ( ( output == FMT_U8 && input == FMT_S8 ) ||
|
||||||
|
( output == FMT_S8 && input == FMT_U8 ) )
|
||||||
|
return convert_swap_sign8;
|
||||||
|
|
||||||
|
if ( ( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_U8 ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_S8 ) ) ) ||
|
||||||
|
( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_U8 ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_S8 ) ) ) )
|
||||||
|
return convert_to_16_native_endian;
|
||||||
|
|
||||||
|
if ( ( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_S8 ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_U8 ) ) ) ||
|
||||||
|
( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_S8 ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_U8 ) ) ) )
|
||||||
|
return convert_to_16_native_endian_swap_sign;
|
||||||
|
|
||||||
|
if ( ( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_U8 ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_S8 ) ) ) ||
|
||||||
|
( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_U8 ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_S8 ) ) ) )
|
||||||
|
return convert_to_16_alien_endian;
|
||||||
|
|
||||||
|
if ( ( !IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_BE && input == FMT_S8 ) ||
|
||||||
|
( output == FMT_S16_BE && input == FMT_U8 ) ) ) ||
|
||||||
|
( IS_BIG_ENDIAN &&
|
||||||
|
( ( output == FMT_U16_LE && input == FMT_S8 ) ||
|
||||||
|
( output == FMT_S16_LE && input == FMT_U8 ) ) ) )
|
||||||
|
return convert_to_16_alien_endian_swap_sign;
|
||||||
|
|
||||||
|
//g_warning( "Translation needed, but not available.\n"
|
||||||
|
// "Input: %d; Output %d.", input, output );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_mono_to_stereo( struct xmms_convert_buffers* buf, void **data, int length, int b16 )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
void *outbuf = convert_get_buffer( &buf->stereo_buffer, length * 2 );
|
||||||
|
|
||||||
|
if ( b16 )
|
||||||
|
{
|
||||||
|
uint16_t *output = outbuf, *input = *data;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
{
|
||||||
|
*output++ = *input;
|
||||||
|
*output++ = *input;
|
||||||
|
input++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint8_t *output = outbuf, *input = *data;
|
||||||
|
for ( i = 0; i < length; i++ )
|
||||||
|
{
|
||||||
|
*output++ = *input;
|
||||||
|
*output++ = *input;
|
||||||
|
input++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*data = outbuf;
|
||||||
|
|
||||||
|
return length * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_mono_to_stereo_8( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
return convert_mono_to_stereo( buf, data, length, FALSE );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_mono_to_stereo_16( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
return convert_mono_to_stereo( buf, data, length, TRUE );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_stereo_to_mono_u8( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint8_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
{
|
||||||
|
uint16_t tmp;
|
||||||
|
tmp = *input++;
|
||||||
|
tmp += *input++;
|
||||||
|
*output++ = tmp / 2;
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
static int convert_stereo_to_mono_s8( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int8_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 2; i++ )
|
||||||
|
{
|
||||||
|
int16_t tmp;
|
||||||
|
tmp = *input++;
|
||||||
|
tmp += *input++;
|
||||||
|
*output++ = tmp / 2;
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
static int convert_stereo_to_mono_u16le( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint16_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 4; i++ )
|
||||||
|
{
|
||||||
|
uint32_t tmp;
|
||||||
|
uint16_t stmp;
|
||||||
|
tmp = GUINT16_FROM_LE( *input );
|
||||||
|
input++;
|
||||||
|
tmp += GUINT16_FROM_LE( *input );
|
||||||
|
input++;
|
||||||
|
stmp = tmp / 2;
|
||||||
|
*output++ = GUINT16_TO_LE( stmp );
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_stereo_to_mono_u16be( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
uint16_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 4; i++ )
|
||||||
|
{
|
||||||
|
uint32_t tmp;
|
||||||
|
uint16_t stmp;
|
||||||
|
tmp = GUINT16_FROM_BE( *input );
|
||||||
|
input++;
|
||||||
|
tmp += GUINT16_FROM_BE( *input );
|
||||||
|
input++;
|
||||||
|
stmp = tmp / 2;
|
||||||
|
*output++ = GUINT16_TO_BE( stmp );
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_stereo_to_mono_s16le( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int16_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 4; i++ )
|
||||||
|
{
|
||||||
|
int32_t tmp;
|
||||||
|
int16_t stmp;
|
||||||
|
tmp = GINT16_FROM_LE( *input );
|
||||||
|
input++;
|
||||||
|
tmp += GINT16_FROM_LE( *input );
|
||||||
|
input++;
|
||||||
|
stmp = tmp / 2;
|
||||||
|
*output++ = GINT16_TO_LE( stmp );
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_stereo_to_mono_s16be( struct xmms_convert_buffers* buf, void **data, int length )
|
||||||
|
{
|
||||||
|
int16_t *output = *data, *input = *data;
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < length / 4; i++ )
|
||||||
|
{
|
||||||
|
int32_t tmp;
|
||||||
|
int16_t stmp;
|
||||||
|
tmp = GINT16_FROM_BE( *input );
|
||||||
|
input++;
|
||||||
|
tmp += GINT16_FROM_BE( *input );
|
||||||
|
input++;
|
||||||
|
stmp = tmp / 2;
|
||||||
|
*output++ = GINT16_TO_BE( stmp );
|
||||||
|
}
|
||||||
|
return length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
convert_channel_func_t xmms_convert_get_channel_func( AFormat fmt, int output, int input )
|
||||||
|
{
|
||||||
|
fmt = unnativize( fmt );
|
||||||
|
|
||||||
|
if ( output == input )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( input == 1 && output == 2 )
|
||||||
|
switch ( fmt )
|
||||||
|
{
|
||||||
|
case FMT_U8:
|
||||||
|
case FMT_S8:
|
||||||
|
return convert_mono_to_stereo_8;
|
||||||
|
case FMT_U16_LE:
|
||||||
|
case FMT_U16_BE:
|
||||||
|
case FMT_S16_LE:
|
||||||
|
case FMT_S16_BE:
|
||||||
|
return convert_mono_to_stereo_16;
|
||||||
|
default:
|
||||||
|
//g_warning( "Unknown format: %d"
|
||||||
|
// "No conversion available.", fmt );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if ( input == 2 && output == 1 )
|
||||||
|
switch ( fmt )
|
||||||
|
{
|
||||||
|
case FMT_U8:
|
||||||
|
return convert_stereo_to_mono_u8;
|
||||||
|
case FMT_S8:
|
||||||
|
return convert_stereo_to_mono_s8;
|
||||||
|
case FMT_U16_LE:
|
||||||
|
return convert_stereo_to_mono_u16le;
|
||||||
|
case FMT_U16_BE:
|
||||||
|
return convert_stereo_to_mono_u16be;
|
||||||
|
case FMT_S16_LE:
|
||||||
|
return convert_stereo_to_mono_s16le;
|
||||||
|
case FMT_S16_BE:
|
||||||
|
return convert_stereo_to_mono_s16be;
|
||||||
|
default:
|
||||||
|
//g_warning( "Unknown format: %d. "
|
||||||
|
// "No conversion available.", fmt );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//g_warning( "Input has %d channels, soundcard uses %d channels\n"
|
||||||
|
// "No conversion is available", input, output );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define RESAMPLE_STEREO( sample_type, bswap ) \
|
||||||
|
do { \
|
||||||
|
const int shift = sizeof ( sample_type ); \
|
||||||
|
int i, in_samples, out_samples, x, delta; \
|
||||||
|
sample_type *inptr = *data, *outptr; \
|
||||||
|
uint nlen = ( ( ( length >> shift ) * ofreq ) / ifreq ); \
|
||||||
|
void *nbuf; \
|
||||||
|
if ( nlen == 0 ) \
|
||||||
|
break; \
|
||||||
|
nlen <<= shift; \
|
||||||
|
if ( bswap ) \
|
||||||
|
convert_swap_endian( NULL, data, length ); \
|
||||||
|
nbuf = convert_get_buffer( &buf->freq_buffer, nlen ); \
|
||||||
|
outptr = nbuf; \
|
||||||
|
in_samples = length >> shift; \
|
||||||
|
out_samples = nlen >> shift; \
|
||||||
|
delta = ( in_samples << 12 ) / out_samples; \
|
||||||
|
for ( x = 0, i = 0; i < out_samples; i++ ) \
|
||||||
|
{ \
|
||||||
|
int x1, frac; \
|
||||||
|
x1 = ( x >> 12 ) << 12; \
|
||||||
|
frac = x - x1; \
|
||||||
|
*outptr++ = \
|
||||||
|
( ( inptr[( x1 >> 12 ) << 1] * \
|
||||||
|
( ( 1<<12 ) - frac ) + \
|
||||||
|
inptr[( ( x1 >> 12 ) + 1 ) << 1] * \
|
||||||
|
frac ) >> 12 ); \
|
||||||
|
*outptr++ = \
|
||||||
|
( ( inptr[( ( x1 >> 12 ) << 1 ) + 1] * \
|
||||||
|
( ( 1<<12 ) - frac ) + \
|
||||||
|
inptr[( ( ( x1 >> 12 ) + 1 ) << 1 ) + 1] * \
|
||||||
|
frac ) >> 12 ); \
|
||||||
|
x += delta; \
|
||||||
|
} \
|
||||||
|
if ( bswap ) \
|
||||||
|
convert_swap_endian( NULL, &nbuf, nlen ); \
|
||||||
|
*data = nbuf; \
|
||||||
|
return nlen; \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
|
|
||||||
|
#define RESAMPLE_MONO( sample_type, bswap ) \
|
||||||
|
do { \
|
||||||
|
const int shift = sizeof ( sample_type ) - 1; \
|
||||||
|
int i, x, delta, in_samples, out_samples; \
|
||||||
|
sample_type *inptr = *data, *outptr; \
|
||||||
|
uint nlen = ( ( ( length >> shift ) * ofreq ) / ifreq ); \
|
||||||
|
void *nbuf; \
|
||||||
|
if ( nlen == 0 ) \
|
||||||
|
break; \
|
||||||
|
nlen <<= shift; \
|
||||||
|
if ( bswap ) \
|
||||||
|
convert_swap_endian( NULL, data, length ); \
|
||||||
|
nbuf = convert_get_buffer( &buf->freq_buffer, nlen ); \
|
||||||
|
outptr = nbuf; \
|
||||||
|
in_samples = length >> shift; \
|
||||||
|
out_samples = nlen >> shift; \
|
||||||
|
delta = ( ( length >> shift ) << 12 ) / out_samples; \
|
||||||
|
for ( x = 0, i = 0; i < out_samples; i++ ) \
|
||||||
|
{ \
|
||||||
|
int x1, frac; \
|
||||||
|
x1 = ( x >> 12 ) << 12; \
|
||||||
|
frac = x - x1; \
|
||||||
|
*outptr++ = \
|
||||||
|
( ( inptr[x1 >> 12] * ( ( 1<<12 ) - frac ) + \
|
||||||
|
inptr[( x1 >> 12 ) + 1] * frac ) >> 12 ); \
|
||||||
|
x += delta; \
|
||||||
|
} \
|
||||||
|
if ( bswap ) \
|
||||||
|
convert_swap_endian( NULL, &nbuf, nlen ); \
|
||||||
|
*data = nbuf; \
|
||||||
|
return nlen; \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
|
static int convert_resample_stereo_s16ne( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( int16_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_stereo_s16ae( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( int16_t, TRUE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_stereo_u16ne( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( uint16_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_stereo_u16ae( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( uint16_t, TRUE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_s16ne( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( int16_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_s16ae( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( int16_t, TRUE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_u16ne( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( uint16_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_u16ae( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( uint16_t, TRUE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_stereo_u8( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( uint8_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_u8( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( uint8_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_stereo_s8( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_STEREO( int8_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int convert_resample_mono_s8( struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq )
|
||||||
|
{
|
||||||
|
RESAMPLE_MONO( int8_t, FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
convert_freq_func_t xmms_convert_get_frequency_func( AFormat fmt, int channels )
|
||||||
|
{
|
||||||
|
fmt = unnativize( fmt );
|
||||||
|
//g_message( "fmt %d, channels: %d", fmt, channels );
|
||||||
|
|
||||||
|
if ( channels < 1 || channels > 2 )
|
||||||
|
{
|
||||||
|
//g_warning( "Unsupported number of channels: %d. "
|
||||||
|
// "Resample function not available", channels );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if ( ( IS_BIG_ENDIAN && fmt == FMT_U16_BE ) ||
|
||||||
|
( !IS_BIG_ENDIAN && fmt == FMT_U16_LE ) )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_u16ne;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_u16ne;
|
||||||
|
}
|
||||||
|
if ( ( IS_BIG_ENDIAN && fmt == FMT_S16_BE ) ||
|
||||||
|
( !IS_BIG_ENDIAN && fmt == FMT_S16_LE ) )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_s16ne;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_s16ne;
|
||||||
|
}
|
||||||
|
if ( ( !IS_BIG_ENDIAN && fmt == FMT_U16_BE ) ||
|
||||||
|
( IS_BIG_ENDIAN && fmt == FMT_U16_LE ) )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_u16ae;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_u16ae;
|
||||||
|
}
|
||||||
|
if ( ( !IS_BIG_ENDIAN && fmt == FMT_S16_BE ) ||
|
||||||
|
( IS_BIG_ENDIAN && fmt == FMT_S16_LE ) )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_s16ae;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_s16ae;
|
||||||
|
}
|
||||||
|
if ( fmt == FMT_U8 )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_u8;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_u8;
|
||||||
|
}
|
||||||
|
if ( fmt == FMT_S8 )
|
||||||
|
{
|
||||||
|
if ( channels == 1 )
|
||||||
|
return convert_resample_mono_s8;
|
||||||
|
else
|
||||||
|
return convert_resample_stereo_s8;
|
||||||
|
}
|
||||||
|
//g_warning( "Resample function not available"
|
||||||
|
// "Format %d.", fmt );
|
||||||
|
return NULL;
|
||||||
|
}
|
43
alsa-playback/xconvert.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2003 Haavard Kvaalen <havardk@xmms.org>
|
||||||
|
*
|
||||||
|
* Licensed under GNU LGPL version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
#define WORDS_BIGENDIAN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
FMT_U8, FMT_S8, FMT_U16_LE, FMT_U16_BE, FMT_U16_NE, FMT_S16_LE, FMT_S16_BE, FMT_S16_NE
|
||||||
|
}
|
||||||
|
AFormat;
|
||||||
|
|
||||||
|
struct xmms_convert_buffers;
|
||||||
|
|
||||||
|
struct xmms_convert_buffers* xmms_convert_buffers_new(void);
|
||||||
|
/*
|
||||||
|
* Free the data assosiated with the buffers, without destroying the
|
||||||
|
* context. The context can be reused.
|
||||||
|
*/
|
||||||
|
void xmms_convert_buffers_free(struct xmms_convert_buffers* buf);
|
||||||
|
void xmms_convert_buffers_destroy(struct xmms_convert_buffers* buf);
|
||||||
|
|
||||||
|
|
||||||
|
typedef int (*convert_func_t)(struct xmms_convert_buffers* buf, void **data, int length);
|
||||||
|
typedef int (*convert_channel_func_t)(struct xmms_convert_buffers* buf, void **data, int length);
|
||||||
|
typedef int (*convert_freq_func_t)(struct xmms_convert_buffers* buf, void **data, int length, int ifreq, int ofreq);
|
||||||
|
|
||||||
|
|
||||||
|
convert_func_t xmms_convert_get_func(AFormat output, AFormat input);
|
||||||
|
convert_channel_func_t xmms_convert_get_channel_func(AFormat fmt, int output, int input);
|
||||||
|
convert_freq_func_t xmms_convert_get_frequency_func(AFormat fmt, int channels);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
data/icons/tomahawk-icon-128.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
data/icons/tomahawk-icon-16.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
data/icons/tomahawk-icon-256.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
data/icons/tomahawk-icon-32.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/tomahawk-icon-512.png
Normal file
After Width: | Height: | Size: 114 KiB |
BIN
data/icons/tomahawk-icon-64.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
data/icons/tomahawk.icns
Normal file
BIN
data/icons/tomahawk.ico
Normal file
After Width: | Height: | Size: 55 KiB |
BIN
data/images/add-friend-button-pressed.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
data/images/add-friend-button-rest.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
data/images/avatar-dude-plus.png
Normal file
After Width: | Height: | Size: 339 B |
BIN
data/images/avatar-dude.png
Normal file
After Width: | Height: | Size: 286 B |
BIN
data/images/back-pressed.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/images/back-rest.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
data/images/magnifying-glass.png
Normal file
After Width: | Height: | Size: 352 B |
BIN
data/images/no-album-art-placeholder.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/images/now-playing-panel.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/images/now-playing-speaker.png
Normal file
After Width: | Height: | Size: 500 B |
BIN
data/images/pause-pressed.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
data/images/pause-rest.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/images/play-pressed.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
data/images/play-rest.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/images/playlist-icon.png
Normal file
After Width: | Height: | Size: 519 B |
BIN
data/images/repeat-1-on-pressed.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
data/images/repeat-1-on-rest.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
data/images/repeat-all-on-pressed.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
data/images/repeat-all-on-rest.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/images/repeat-off-pressed.png
Normal file
After Width: | Height: | Size: 723 B |
BIN
data/images/repeat-off-rest.png
Normal file
After Width: | Height: | Size: 707 B |
BIN
data/images/search-box-dismiss-x.png
Normal file
After Width: | Height: | Size: 410 B |
BIN
data/images/search-box.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
data/images/seek-and-volume-knob-pressed.png
Normal file
After Width: | Height: | Size: 522 B |
BIN
data/images/seek-and-volume-knob-rest.png
Normal file
After Width: | Height: | Size: 519 B |
BIN
data/images/seek-slider-bkg.png
Normal file
After Width: | Height: | Size: 398 B |
BIN
data/images/seek-slider-level.png
Normal file
After Width: | Height: | Size: 397 B |
BIN
data/images/shuffle-off-pressed.png
Normal file
After Width: | Height: | Size: 627 B |
BIN
data/images/shuffle-off-rest.png
Normal file
After Width: | Height: | Size: 634 B |
BIN
data/images/shuffle-on-pressed.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/images/shuffle-on-rest.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
data/images/skip-pressed.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/images/skip-rest.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
data/images/source-off-pressed.png
Normal file
After Width: | Height: | Size: 844 B |
BIN
data/images/source-off-rest.png
Normal file
After Width: | Height: | Size: 858 B |
BIN
data/images/source-on-pressed.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/images/source-on-rest.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/images/status-alert-icon.png
Normal file
After Width: | Height: | Size: 589 B |
BIN
data/images/status-bar-bkg.png
Normal file
After Width: | Height: | Size: 301 B |
BIN
data/images/status-dismiss-x.png
Normal file
After Width: | Height: | Size: 530 B |
BIN
data/images/user-avatar.png
Normal file
After Width: | Height: | Size: 324 B |
BIN
data/images/view-toggle-active-centre.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
data/images/view-toggle-active-left.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
data/images/view-toggle-active-right.png
Normal file
After Width: | Height: | Size: 386 B |
BIN
data/images/view-toggle-icon-artist-active.png
Normal file
After Width: | Height: | Size: 192 B |
BIN
data/images/view-toggle-icon-artist-inactive.png
Normal file
After Width: | Height: | Size: 312 B |
BIN
data/images/view-toggle-icon-cloud-active.png
Normal file
After Width: | Height: | Size: 428 B |
BIN
data/images/view-toggle-icon-cloud-inactive.png
Normal file
After Width: | Height: | Size: 460 B |
BIN
data/images/view-toggle-icon-list-active.png
Normal file
After Width: | Height: | Size: 177 B |
BIN
data/images/view-toggle-icon-list-inactive.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
data/images/view-toggle-inactive-centre.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
data/images/view-toggle-inactive-left.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
data/images/view-toggle-inactive-right.png
Normal file
After Width: | Height: | Size: 419 B |
BIN
data/images/view-toggle-pressed-centre.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
data/images/view-toggle-pressed-left.png
Normal file
After Width: | Height: | Size: 335 B |
BIN
data/images/view-toggle-pressed-right.png
Normal file
After Width: | Height: | Size: 367 B |
BIN
data/images/volume-icon-full.png
Normal file
After Width: | Height: | Size: 815 B |
BIN
data/images/volume-icon-muted.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
data/images/volume-slider-bkg.png
Normal file
After Width: | Height: | Size: 344 B |
BIN
data/images/volume-slider-level.png
Normal file
After Width: | Height: | Size: 340 B |
55
data/topbar-radiobuttons.css
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
QWidget#widgetRadio {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioButton {
|
||||||
|
border: 0;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
background-repeat: none;
|
||||||
|
/*width:0; height:0;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioButton::indicator {
|
||||||
|
width: 29px;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioButton::indicator::unchecked {
|
||||||
|
background-image: url(:/data/images/view-toggle-inactive-centre.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-artist-inactive.png);
|
||||||
|
}
|
||||||
|
QRadioButton::indicator::checked {
|
||||||
|
background-image: url(:/data/images/view-toggle-active-centre.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-artist-active.png);
|
||||||
|
}
|
||||||
|
QRadioButton::indicator::pressed {
|
||||||
|
background-image: url(:/data/images/view-toggle-pressed-centre.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-artist-active.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioNormal::indicator::unchecked {
|
||||||
|
background-image: url(:/data/images/view-toggle-inactive-left.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-list-inactive.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioNormal::indicator::checked {
|
||||||
|
background-image: url(:/data/images/view-toggle-active-left.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-list-active.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioNormal::indicator::pressed {
|
||||||
|
background-image: url(:/data/images/view-toggle-pressed-left.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-list-active.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioCloud::indicator::unchecked {
|
||||||
|
background-image: url(:/data/images/view-toggle-inactive-right.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-cloud-inactive.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioCloud::indicator::checked {
|
||||||
|
background-image: url(:/data/images/view-toggle-active-right.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-cloud-active.png);
|
||||||
|
}
|
||||||
|
QRadioButton#radioCloud::indicator::pressed {
|
||||||
|
background-image: url(:/data/images/view-toggle-pressed-right.png);
|
||||||
|
image: url(:/data/images/view-toggle-icon-cloud-active.png);
|
||||||
|
}
|
13
gen_resources.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "<!DOCTYPE RCC><RCC version=\"1.0\"><qresource>"
|
||||||
|
|
||||||
|
datadir="`pwd`/data"
|
||||||
|
|
||||||
|
cd "$datadir"
|
||||||
|
(find -type f | sed 's/^\.\///g') | while read f
|
||||||
|
do
|
||||||
|
ff="${datadir}/$f"
|
||||||
|
echo "<file alias=\"$f\">$ff</file>"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "</qresource></RCC>"
|
35
include/tomahawk/album.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef TOMAHAWKALBUM_H
|
||||||
|
#define TOMAHAWKALBUM_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "artist.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class Album;
|
||||||
|
typedef QSharedPointer<Album> album_ptr;
|
||||||
|
|
||||||
|
class Album : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Album( artist_ptr artist, const QString& name )
|
||||||
|
: m_name( name )
|
||||||
|
, m_artist( artist )
|
||||||
|
{}
|
||||||
|
|
||||||
|
const QString& name() const { return m_name; }
|
||||||
|
const artist_ptr artist() const { return m_artist; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_name;
|
||||||
|
artist_ptr m_artist;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
#endif
|
30
include/tomahawk/artist.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef TOMAHAWKARTIST_H
|
||||||
|
#define TOMAHAWKARTIST_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class Artist;
|
||||||
|
typedef QSharedPointer<Artist> artist_ptr;
|
||||||
|
|
||||||
|
class Artist : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Artist( const QString& name )
|
||||||
|
: m_name( name )
|
||||||
|
{};
|
||||||
|
|
||||||
|
const QString& name() const { return m_name; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
#endif
|
100
include/tomahawk/collection.h
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
The collection - acts as container for someones music library
|
||||||
|
load() -> async populate by calling addArtists etc,
|
||||||
|
then finishedLoading() is emitted.
|
||||||
|
then use artists() etc to get the data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TOMAHAWK_COLLECTION_H
|
||||||
|
#define TOMAHAWK_COLLECTION_H
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
#include <QList>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "tomahawk/functimeout.h"
|
||||||
|
#include "tomahawk/playlist.h"
|
||||||
|
#include "tomahawk/source.h"
|
||||||
|
#include "tomahawk/typedefs.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
Call load(), then wait for the finishedLoading() signal,
|
||||||
|
then call tracks() to get all tracks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Collection : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Collection( const source_ptr& source, const QString& name, QObject* parent = 0 );
|
||||||
|
virtual ~Collection();
|
||||||
|
|
||||||
|
void invokeSlotTracks( QObject* obj, const char* slotname, const QList<QVariant>& val, collection_ptr collection );
|
||||||
|
|
||||||
|
virtual QString name() const;
|
||||||
|
|
||||||
|
virtual void loadPlaylists() = 0;
|
||||||
|
|
||||||
|
virtual Tomahawk::playlist_ptr playlist( const QString& guid );
|
||||||
|
virtual void addPlaylist( const Tomahawk::playlist_ptr& p );
|
||||||
|
virtual void deletePlaylist( const Tomahawk::playlist_ptr& p );
|
||||||
|
|
||||||
|
/// async calls that fetch data from DB/whatever:
|
||||||
|
void loadTracks( QObject* obj, const char* slotname );
|
||||||
|
|
||||||
|
virtual const QList< Tomahawk::playlist_ptr >& playlists() const { return m_playlists; }
|
||||||
|
|
||||||
|
bool isLoaded() const { return m_loaded; }
|
||||||
|
|
||||||
|
const source_ptr& source() const { return m_source; }
|
||||||
|
unsigned int lastmodified() const { return m_lastmodified; }
|
||||||
|
|
||||||
|
static bool trackSorter( const QVariant& left, const QVariant &right );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void tracksAdded( const QList<QVariant>&, Tomahawk::collection_ptr );
|
||||||
|
void tracksRemoved( const QList<QVariant>&, Tomahawk::collection_ptr );
|
||||||
|
|
||||||
|
void playlistsAdded( const QList<Tomahawk::playlist_ptr>& );
|
||||||
|
void playlistsDeleted( const QList<Tomahawk::playlist_ptr>& );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void addTracks( const QList<QVariant> &newitems ) = 0;
|
||||||
|
virtual void removeTracks( const QList<QVariant> &olditems ) = 0;
|
||||||
|
|
||||||
|
void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << plists.length();
|
||||||
|
m_playlists.append( plists );
|
||||||
|
if( !m_loaded )
|
||||||
|
{
|
||||||
|
m_loaded = true;
|
||||||
|
emit playlistsAdded( plists );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void loadAllTracks( boost::function<void( const QList<QVariant>&, collection_ptr )> callback ) = 0;
|
||||||
|
|
||||||
|
QString m_name;
|
||||||
|
bool m_loaded;
|
||||||
|
unsigned int m_lastmodified; // unix time of last change to collection
|
||||||
|
|
||||||
|
private:
|
||||||
|
source_ptr m_source;
|
||||||
|
QList< Tomahawk::playlist_ptr > m_playlists;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
inline uint qHash( const QSharedPointer<Tomahawk::Collection>& key )
|
||||||
|
{
|
||||||
|
return qHash( (void *)key.data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TOMAHAWK_COLLECTION_H
|
51
include/tomahawk/functimeout.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef FUNCTIMEOUT_H
|
||||||
|
#define FUNCTIMEOUT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "boost/function.hpp"
|
||||||
|
#include "boost/bind.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
I want to do:
|
||||||
|
QTimer::singleShot(1000, this, SLOT(doSomething(x)));
|
||||||
|
instead, I'm doing:
|
||||||
|
new FuncTimeout(1000, boost::bind(&MyClass::doSomething, this, x));
|
||||||
|
|
||||||
|
*/
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class FuncTimeout : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FuncTimeout( int ms, boost::function<void()> func )
|
||||||
|
: m_func( func )
|
||||||
|
{
|
||||||
|
//qDebug() << Q_FUNC_INFO;
|
||||||
|
QTimer::singleShot( ms, this, SLOT(exec() ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
~FuncTimeout()
|
||||||
|
{
|
||||||
|
//qDebug() << Q_FUNC_INFO;
|
||||||
|
};
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void exec()
|
||||||
|
{
|
||||||
|
m_func();
|
||||||
|
this->deleteLater();
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::function<void()> m_func;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
#endif // FUNCTIMEOUT_H
|
70
include/tomahawk/pipeline.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef PIPELINE_H
|
||||||
|
#define PIPELINE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
#include "tomahawk/typedefs.h"
|
||||||
|
#include "tomahawk/query.h"
|
||||||
|
#include "tomahawk/result.h"
|
||||||
|
#include "tomahawk/resolver.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class Resolver;
|
||||||
|
|
||||||
|
class Pipeline : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Pipeline( QObject* parent = 0 );
|
||||||
|
|
||||||
|
// const query_ptr& query( QID qid ) const;
|
||||||
|
// result_ptr result( RID rid ) const;
|
||||||
|
|
||||||
|
void reportResults( QID qid, const QList< result_ptr >& results );
|
||||||
|
|
||||||
|
/// sorter to rank resolver priority
|
||||||
|
static bool resolverSorter( const Resolver* left, const Resolver* right );
|
||||||
|
|
||||||
|
void addResolver( Resolver* r, bool sort = true );
|
||||||
|
void removeResolver( Resolver* r );
|
||||||
|
|
||||||
|
query_ptr query( const QID& qid ) const
|
||||||
|
{
|
||||||
|
return m_qids.value( qid );
|
||||||
|
}
|
||||||
|
|
||||||
|
result_ptr result( const RID& rid ) const
|
||||||
|
{
|
||||||
|
return m_rids.value( rid );
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void add( const query_ptr& q );
|
||||||
|
void add( const QList<query_ptr>& qlist );
|
||||||
|
void databaseReady();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void shunt( const query_ptr& q );
|
||||||
|
void indexReady();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList< Resolver* > m_resolvers;
|
||||||
|
QMap< QID, query_ptr > m_qids;
|
||||||
|
QMap< RID, result_ptr > m_rids;
|
||||||
|
|
||||||
|
QMutex m_mut; // for m_qids, m_rids
|
||||||
|
|
||||||
|
// store queries here until DB index is loaded, then shunt them all
|
||||||
|
QList< query_ptr > m_queries_pending;
|
||||||
|
bool m_index_ready;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; //ns
|
||||||
|
|
||||||
|
#endif // PIPELINE_H
|
190
include/tomahawk/playlist.h
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
#ifndef PLAYLIST_H
|
||||||
|
#define PLAYLIST_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "tomahawk/query.h"
|
||||||
|
#include "tomahawk/typedefs.h"
|
||||||
|
|
||||||
|
class DatabaseCommand_LoadAllPlaylists;
|
||||||
|
class DatabaseCommand_SetPlaylistRevision;
|
||||||
|
class DatabaseCommand_CreatePlaylist;
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class PlaylistEntry : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
||||||
|
Q_PROPERTY( QString annotation READ annotation WRITE setAnnotation )
|
||||||
|
Q_PROPERTY( QString resulthint READ resulthint WRITE setResulthint )
|
||||||
|
Q_PROPERTY( unsigned int duration READ duration WRITE setDuration )
|
||||||
|
Q_PROPERTY( unsigned int lastmodified READ lastmodified WRITE setLastmodified )
|
||||||
|
Q_PROPERTY( QVariant query READ queryvariant WRITE setQueryvariant )
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setQuery( const Tomahawk::query_ptr& q ) { m_query = q; }
|
||||||
|
const Tomahawk::query_ptr& query() const { return m_query; }
|
||||||
|
|
||||||
|
// I wish Qt did this for me once i specified the Q_PROPERTIES:
|
||||||
|
void setQueryvariant( const QVariant& v );
|
||||||
|
QVariant queryvariant() const;
|
||||||
|
|
||||||
|
QString guid() const { return m_guid; }
|
||||||
|
void setGuid( const QString& s ) { m_guid = s; }
|
||||||
|
|
||||||
|
QString annotation() const { return m_annotation; }
|
||||||
|
void setAnnotation( const QString& s ) { m_annotation = s; }
|
||||||
|
|
||||||
|
QString resulthint() const { return m_resulthint; }
|
||||||
|
void setResulthint( const QString& s ) { m_resulthint= s; }
|
||||||
|
|
||||||
|
unsigned int duration() const { return m_duration; }
|
||||||
|
void setDuration( unsigned int i ) { m_duration = i; }
|
||||||
|
|
||||||
|
unsigned int lastmodified() const { return m_lastmodified; }
|
||||||
|
void setLastmodified( unsigned int i ) { m_lastmodified = i; }
|
||||||
|
|
||||||
|
source_ptr lastsource() const { return m_lastsource; }
|
||||||
|
void setLastsource( source_ptr s ) { m_lastsource = s ; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_guid;
|
||||||
|
Tomahawk::query_ptr m_query;
|
||||||
|
QString m_annotation;
|
||||||
|
unsigned int m_duration;
|
||||||
|
unsigned int m_lastmodified;
|
||||||
|
source_ptr m_lastsource;
|
||||||
|
QString m_resulthint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct PlaylistRevision
|
||||||
|
{
|
||||||
|
QString revisionguid;
|
||||||
|
QString oldrevisionguid;
|
||||||
|
QList<plentry_ptr> newlist;
|
||||||
|
QList<plentry_ptr> added;
|
||||||
|
QList<plentry_ptr> removed;
|
||||||
|
bool applied; // false if conflict
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Playlist : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
||||||
|
Q_PROPERTY( QString currentrevision READ currentrevision WRITE setCurrentrevision )
|
||||||
|
Q_PROPERTY( QString title READ title WRITE setTitle )
|
||||||
|
Q_PROPERTY( QString info READ info WRITE setInfo )
|
||||||
|
Q_PROPERTY( QString creator READ creator WRITE setCreator )
|
||||||
|
Q_PROPERTY( bool shared READ shared WRITE setShared )
|
||||||
|
|
||||||
|
friend class ::DatabaseCommand_LoadAllPlaylists;
|
||||||
|
friend class ::DatabaseCommand_SetPlaylistRevision;
|
||||||
|
friend class ::DatabaseCommand_CreatePlaylist;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// one CTOR is private, only called by DatabaseCommand_LoadAllPlaylists
|
||||||
|
static Tomahawk::playlist_ptr create( const source_ptr& author,
|
||||||
|
const QString& guid,
|
||||||
|
const QString& title,
|
||||||
|
const QString& info,
|
||||||
|
const QString& creator,
|
||||||
|
bool shared );
|
||||||
|
|
||||||
|
static bool remove( const playlist_ptr& playlist );
|
||||||
|
|
||||||
|
virtual void loadRevision( const QString& rev = "" );
|
||||||
|
|
||||||
|
const source_ptr& author() { return m_source; }
|
||||||
|
const QString& currentrevision() { return m_currentrevision; }
|
||||||
|
const QString& title() { return m_title; }
|
||||||
|
const QString& info() { return m_info; }
|
||||||
|
const QString& creator() { return m_creator; }
|
||||||
|
unsigned int lastmodified() { return m_lastmodified; }
|
||||||
|
const QString& guid() { return m_guid; }
|
||||||
|
bool shared() const { return m_shared; }
|
||||||
|
|
||||||
|
const QList< plentry_ptr >& entries() { return m_entries; }
|
||||||
|
void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||||
|
void addEntries( const QList<Tomahawk::query_ptr>& queries, const QString& oldrev );
|
||||||
|
|
||||||
|
// <IGNORE hack="true">
|
||||||
|
// these need to exist and be public for the json serialization stuff
|
||||||
|
// you SHOULD NOT call them. They are used for an alternate CTOR method from json.
|
||||||
|
// maybe friend QObjectHelper and make them private?
|
||||||
|
Playlist( const source_ptr& author ) :
|
||||||
|
m_source( author )
|
||||||
|
, m_lastmodified( 0 )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "JSON";
|
||||||
|
}
|
||||||
|
void setCurrentrevision( const QString& s ) { m_currentrevision = s; }
|
||||||
|
void setTitle( const QString& s ) { m_title= s; }
|
||||||
|
void setInfo( const QString& s ) { m_info = s; }
|
||||||
|
void setCreator( const QString& s ) { m_creator = s; }
|
||||||
|
void setGuid( const QString& s ) { m_guid = s; }
|
||||||
|
void setShared( bool b ) { m_shared = b; }
|
||||||
|
// </IGNORE>
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/// emitted when the playlist revision changes (whenever the playlist changes)
|
||||||
|
void revisionLoaded( Tomahawk::PlaylistRevision );
|
||||||
|
|
||||||
|
/// watch for this to see when newly created playlist is synced to DB (if you care)
|
||||||
|
void created();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// want to update the playlist from the model?
|
||||||
|
// generate a newrev using uuid() and call this:
|
||||||
|
void createNewRevision( const QString& newrev, const QString& oldrev, const QList< plentry_ptr >& entries );
|
||||||
|
void reportCreated( const Tomahawk::playlist_ptr& self );
|
||||||
|
void reportDeleted( const Tomahawk::playlist_ptr& self );
|
||||||
|
|
||||||
|
void setRevision( const QString& rev,
|
||||||
|
const QList<QString>& neworderedguids,
|
||||||
|
const QList<QString>& oldorderedguids,
|
||||||
|
bool is_newest_rev,
|
||||||
|
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
|
||||||
|
bool applied );
|
||||||
|
|
||||||
|
void resolve();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// called from loadAllPlaylists DB cmd:
|
||||||
|
explicit Playlist( const source_ptr& src,
|
||||||
|
const QString& currentrevision,
|
||||||
|
const QString& title,
|
||||||
|
const QString& info,
|
||||||
|
const QString& creator,
|
||||||
|
bool shared,
|
||||||
|
int lastmod,
|
||||||
|
const QString& guid = "" ); // populate db
|
||||||
|
|
||||||
|
// called when creating new playlist
|
||||||
|
explicit Playlist( const source_ptr& author,
|
||||||
|
const QString& guid,
|
||||||
|
const QString& title,
|
||||||
|
const QString& info,
|
||||||
|
const QString& creator,
|
||||||
|
bool shared );
|
||||||
|
|
||||||
|
void rundb();
|
||||||
|
|
||||||
|
source_ptr m_source;
|
||||||
|
QString m_currentrevision;
|
||||||
|
QString m_guid, m_title, m_info, m_creator;
|
||||||
|
unsigned int m_lastmodified;
|
||||||
|
bool m_shared;
|
||||||
|
|
||||||
|
QList< plentry_ptr > m_entries;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLAYLIST_H
|
34
include/tomahawk/playlistmodelinterface.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef PLAYLISTINTERFACE_H
|
||||||
|
#define PLAYLISTINTERFACE_H
|
||||||
|
|
||||||
|
#include "playlistitem.h"
|
||||||
|
#include "tomahawk/collection.h"
|
||||||
|
#include "tomahawk/source.h"
|
||||||
|
|
||||||
|
class PlaylistModelInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
|
|
||||||
|
virtual ~PlaylistModelInterface() {}
|
||||||
|
|
||||||
|
virtual PlaylistItem* previousItem() = 0;
|
||||||
|
virtual PlaylistItem* nextItem() = 0;
|
||||||
|
virtual PlaylistItem* siblingItem( int itemsAway ) = 0;
|
||||||
|
virtual void setCurrentItem( const QModelIndex& index ) = 0;
|
||||||
|
|
||||||
|
virtual unsigned int sourceCount() = 0;
|
||||||
|
virtual unsigned int collectionCount() = 0;
|
||||||
|
virtual unsigned int trackCount() = 0;
|
||||||
|
virtual unsigned int artistCount() = 0;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void setRepeatMode( RepeatMode mode ) = 0;
|
||||||
|
virtual void setShuffled( bool enabled ) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
virtual void repeatModeChanged( PlaylistModelInterface::RepeatMode mode ) = 0;
|
||||||
|
virtual void shuffleModeChanged( bool enabled ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLAYLISTINTERFACE_H
|