ffmpeg parses TDA, TDAT, TYE, TYER and TDR these days, so there is no need
to do that in forked-daapd. Also the parsing of TDA/TDAT was incorrect,
since it is MMDD.
This change aligns with iTunes behavior. It also means that a client that is
not long polling can use the revision number (cmsr) value to check for changes.
If the number of quality subscriptions reaches max then this bug will be
triggered, because we will incorrectly use the last element of the
output_buffer for a subscription, thus losing the zero terminator.
Extends the playlist table with media_kind to handle playlist queries like
this from Apple Music:
/databases/71/containers?session-id=12345678&revision-number=4&delta=0&query=('dmap.itemname:Library%20name','com.apple.itunes.extended-media-kind:1','com.apple.itunes.extended-media-kind:32','com.apple.itunes.extended-media-kind:128','com.apple.itunes.extended-media-kind:65537')&meta=dmap.itemid,dmap.itemname,dmap.persistentid,dmap.parentcontainerid,com.apple.itunes.is-podcast-playlist,com.apple.itunes.special-playlist,com.apple.itunes.smart-playlist,dmap.haschildcontainers,com.apple.itunes.saved-genius,dmap.objectextradata
Like with iTunes, it has adverse effects to announce support for DAAP groups,
so with this change we also check if user-agent is "Music" before deciding what
to announce.
Setting Cache-Control to "no-cache" tells a client to always make a
request to check if the version in the client cache is still valid
(response code 403 not modified).
The player will write 24 bit samples using 3 bytes, not 4, so the appropriate
sample format is SND_PCM_FORMAT_S24_3LE, not SND_PCM_FORMAT_S24_LE.
For extra protection we also use snd_pcm_bytes_to_frames() instead of BTOS(),
because that way we can be more certain that the buffer is not too short for
snd_pcm_writei().
Also changes relative seeking behavior:
- seeking behind the the current track only switches to the previous
track, if we are not more than 3 seconds into the current track,
otherwise starts current track from the beginning
- seeking beyond the current track will start the next track from the
beginning
This implementation uses a tmpfile for storage of the artwork, plus it uses
artwork_get() which means that it scales the image as requested by the client.
It also does not create a tmpfile unless we actually receive artwork.
When pipe playback is started, but no data is written to the pipe, the input
loop would bring the cpu to 100%. This fix limits the loop like it was before
player refactor.
This adds a new settings component for user configurable options that
can be changed through the JSON API.
The settings are stored in the admin db table and not in the conf-file.
Since it is unknown how to do real sync on Chromecast, this commit instead adds
a primitive delay to the stream, so that it is at least somewhat closer to
Airplay/local audio.
Also some cleanup of unused stuff.
* [db,jsonapi] case insensitive directory/file listing
* [jsonapi] file listing of playlist uses same VPATH ordering as per directory and files
* [db,jsonapi] sorting via existing S_VPATH
* [db] replace LOWER with COLLATE NOCASE
pb_suspend() + pb_resume() during track changes made the playback status
incorrect, i.e. pb_session.source_list/playing_now would not match what the
input was actually writing. This attempts to solve it by resetting the
session when pb_suspend() is called, so that the input, input_buffer and
source_list come into sync.
If playback was paused during the very last part of the track, the rest of the
track would be read into the input buffer and the input would be closed. With
this commit the input will not be reopened.
Also allow input_flush to be called with null argument.
Fixes bugs which were due to incorrect handling of unsigned integer wrap-around:
1. Calling packet_resend() with seqnum + len greater than UINT16_MAX => infinite loop
2. Calling rtp_packet_get() with session->seqnum - seqnum greater than pktbuf_next => wrong packet
This fixes a bug from commit 37ce8dd6 where seek_http (which is called when
pausing playback) for non-seekable streams would return -1, thus signalling
an error, even though it is not. The player would think that the stream
could not be played and then skip to the next item.
The fix in commit 3928ab6 broke resuming from an underrun, since it meant that
pb_resume() would flush the input buffer. With this fix it is possible to call
input_resume(), which will not flush the buffer if the source is already open.
Also renamed some functions in player.c for consistency.
For dates that require context (ie today, yesterday, N days ago etc) we want the
underlying SQL to respect the current time when running query; a query that
requests items for 'today' should only find matches for the time it was run.
Current implementation would generated a fixed date (at the time the SMARTPL is
inserted into db) in the playlist table where as this commit understands the
context of the date.
* Fix "clicks" during playback, especially on low buffer size devices
Bug had two causes: Trying to write to the prebuf ringbuffer when it was full
and writing new audio to the device without first having drained the prebuf,
thus writing out of order.
* Use snd_pcm_drain() so alsa doesn't report underrun on playback session end
Removes SNDRV_PCM_IOCTL_SYNC_PTR errors
* Fix missing error check of the return value from snd_pcm_avail (now use snd_pcm_avail_delay)
The previous solution would use subqueries to count the number of items and
streams in each playlist, which means that response time gets pretty slow if
there are many playlists.
This commit also includes a number of lesser db code changes.
Commit b3bfb0a and e1993bc change the triggers and calculation of id's in a way
that is not backwards compatible, so we need to make major schema upgrade.
The purpose of this is to support library backends making their own
calculation of these id's, which is relevant if they have more information
available than just album_artist and album.
This also removes a bunch of sqlite extension code plus some triggers, which
in itself is probably an improvement.
Replace reading_next and reading_prev with a list of sources, so that we can
deal with short tracks, i.e. tracks where reading ends before playback starts.
With short tracks reading ends before playback starts, so event_read_eof comes
before event_play_start, which causes playing_now to point to a null
reading_now.
With this change it will point to a non-null reading_prev, but note that in the
hopefully rare case of multiple short tracks, the playing_now pointer will
still be incorrect.
ffmpeg changed the behaviour of avcodec_default_get_format() so that it picks
AV_PIX_FMT_MONOBLACK instead of AV_PIX_FMT_RGB24 for the png encoder. That
makes the function of no use to us, so now the pix formats are just hardcoded
in the settings instead.
This change is preparation to use ffmpeg's resampling capabilities to keep local
audio in sync (by up/downsampling slightly). This requires that sample rates are
not fixed for a transcode profile.
Added benefit of this is that we don't need quite as many xcode profiles.
Previously input_metadata_get() would retrieve artwork from the source being
read currently, which might not be the one that triggered the FLAG_METADATA
event. So to fix this the metadata is now read by the input module itself when
the METADATA event happens, and the result is stored with the marker.
The commit also includes a timer so that the input thread does loop forever
if the player never starts reading.
Also some refactoring of metadata + abolish input_metadata_get and
input_quality_get. The latter in an attempt to treat the two in the same way.
In the output implementations playback_stop() was somewhat redundant,
since device_stop() does the same.
The timer should make sure that we always close outputs (previously
they were in some cases kept open).
The commit also includes some renaming.
After an underrun the player doesn't read, so that meant input_wait would
wait a second before allowing the input to write, even though the input_buffer
was not full
+ remember to flush in source_start(), since the input won't do it if
input_now_reading has already been closed (e.g. if starting a new track
while playback is at the end of another track)
Player now stops 10 secs after stop command and 10 mins after pause. At
that time the outputs have probably cut the connection themselves, but
that might be ok (needs testing).
* Also call full_cb() from input_wait if buffer is full
* Make read_deficit count missing bytes instead of clock ticks
* Make read_deficit a part of the playback session
The time stamp was getting set too late, because if pos was zero the first
reads then it would be overwritten, but it shouldn't because the loop will
catch up even if the initial reads have zero samples.
* Drop output_sessions, was just a pointer to the actual session anyway
* Drop the old write, flush and stop prototypes
* Some minor changes/renaming
Purpose of this is also to fix a race condition in player.c where it
could try to start two sessions on the same speaker. This could happen
because outputs_device_start() in line 2093 is conditional on device->session
which however is false while a device is starting up.
outputs_playback_start() had the problem that was not consistently invoked: If
for instance local audio playback was running and a Airplay device was then
activated, the raop's playback_start would never be invoked (and vice versa,
of course).
Instead, the player now writes the presentation timestamp every time to the
output, so it doesn't need to keep track of it from the start.
* Untie Airtunes stuff further from player and non-Airplay outputs
* Change raop.c to use rtp_common.c (step 1)
* Change heartbeat of player to 100 ticks/sec, since we have untied from
Airtunes 352 samples per packet (which equals 126 ticks/sec at 44100)
Still a lot to be done in the player, since the rtptime's in it don't
are probably broken.
Output module can now take input data in multiple quality levels, and
can resample to those output modules that would require a certain quality
level, like raop.c would
Extends the http_client_ctx to hold the response code for a request.
Also adds the content type header, if it was a https request (using
libcurl instead of libevent)
This adds a new timestamp value "db_modified" into the admin db table.
In addition to the existing "db_update" admin value, this value is also
updated if rating, play-/skip-count or seek changes for a
media_info_file (files db table).
This should improve the caching behavior in clients of the JSON API
(especially the player web interface) in refreshing its data if some of
this values changes.
New endpoint is PUT api/library/tracks/[id] and supported query
parameters are:
- rating: with values between 0 and 100
- play_count: with values "reset" (resets play_count and skip_count) or
"increment" (increments play_count)
"Play Date" tag was seconds since 1904 (an Apple Mac HFS+ timestamp), not a
Unix timestamp as we assumed. Seems Apple themselves realised that wasn't a
great idea (+ not a proper plist date type), and therefore provide "Play Date
UTC" as an alternative.