c,spotify,libspotifyRelated issues-Collection of common programming errors
Potatoswatter
c portability binaryfiles endianness htonl
As far as I know, the C library provides no help in serializing numeric values into a non-text byte stream. Correct me if I’m wrong.The most standard tool in use is htonl et al from POSIX. These functions have shortcomings:There is no 64-bit support. There is no floating-point support. There are no versions for signed types. When deserializing, the unsigned-to-signed conversion relies on signed integral overflow which is UB. Their names do not state the size of the datatype. They depend on 8-bit
umläute
c video udp streaming gstreamer
I have a problem with sending a videostream over UDP.If I start a pipeline from the commandline, it works fine (it is from here)gst-launch-0.10 -v gstrtpbin name=rtpbin v4l2src device=/dev/video0 ! videorate !videoscale ! ffmpegcolorspace ! ‘video/x-raw-yuv, width=(int)600, height=(int)480, framerate=(fraction)15/1’ ! rtpvrawpay ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! multiudpsink clients=”192.168.220.54:9996″ rtpbin.send_rtcp_src_0 ! multiudpsink clients=”192.168.220.54:9997″ sync=fal
yota
c dynamic-library fpic
I made a piece of code which consists in a dynamic library (lib.c), and a main executable (main.c). In both files I define a global variable named: int global. Not very smart but it’s not the question.When I compile the dynamic library the -fPIC option seems mandatory:gcc lib.c -fPIC -shared -o lib.sootherwise I get:/usr/bin/ld: /tmp/ccpUvIPj.o: relocation R_X86_64_32 against ‘.rodata’ can not be used when making a shared object; recompile with -fPICWhen I compile the executable it is not.gcc ma
Mehrdad
c++ c
I tested right shift with Visual Studio, Ubuntu’s GCC, Intel compiler, MinGW. All shift in the sign bit. I guess Xcode’s GCC does the same. I know that the behavior is implementation specific, but it looks like that all major desktop/server compilers implement arithmetic shift. Are there any widely used compiler that doesn’t shift in the sign bit?Thank you.
tjgreen
c postgresql ocaml
I am faced with the task of building a new component to be integrated into a large existing C codebase. The component is essentially a kind of compiler, and will be complicated enough that I would like to write it in OCaml (for reasons along the lines of those given here). I know that OCaml-C interaction is possible (as per the manual and this tutorial), but it looks somewhat painful.What I’d like to know is whether others here have attempted large-scale integration of OCaml and C code, what w
user3043746
c sorting optimization bubble-sort
I was looking at wikipedia’s bsort page and I tried to implement the two optimized versions that are in pseudo code in C, but the results don’t seem to add up. Here’s my code:Implementation 1:#include <stdio.h>#define SWAP(a, b) (a ^= b ^= a ^= b)void tbsort(int a[], int n) {int i, swapped;do {swapped = 0;for (i = 1; i <= n – 1; i++) {if (a[i – 1] > a[i]) {SWAP(a[i – 1], a[i]);swapped = 1;} }n -= 1;} while (!swapped);for (i = 0; i < 10; i++)printf(“%d ->”, a[i]);putchar(‘\n’);
Lightness Races in Orbit
c++ c return-value return
Very often you have a function, which for given arguments can’t generate valid result or it can’t perform some tasks. Apart from exceptions, which are not so commonly used in C/C++ world, there are basically two schools of reporting invalid results.First approach mixes valid returns with a value which does not belong to codomain of a function (very often -1) and indicates an errorint foo(int arg) {if (everything fine)return some_value;return -1; //on failure }The scond approach is to return a f
Jonathan Leffler
c++ c
I need to parse a C++ stdin input which looks something like this:N M (pairs)0 0 2 1 (0,1) 2 0 5 8 (0,1) (1,3) (2,3) (0,2) (0,1) (2,3) (2,4) (2,4)If N > 0 && M > 0, then M pairs will follow. It is a single line input so I have no idea how to do it.I have some solution, but something tells me it’s not the best one.void input(){int a[100][2];int n,m;char ch;cin >> n >> m;for ( int i = 0; i < m; i++) {cin >> ch >> a[i][0]>> ch>> a[i][1]>>ch; }
alk
c printf gnu sprintf
I’m having a hard time understanding why you would need asprintf. Here in the manual it saysThe functions asprintf() and vasprintf() are analogs of sprintf(3) andvsprintf(3), except that they allocate a string large enough to holdthe output including the terminating null byte, and return a pointerto it via the first argument. This pointer should be passed tofree(3) to release the allocated storage when it is no longer needed.So here is the example that I’m trying to understand:asprintf(&bu
Ben Voigt
c++ c optimization language-lawyer undefined-behavior
I was reading this paper on undefined behaviour and one of the example “optimisations” looks highly dubious:if (arg2 == 0)ereport(ERROR, (errcode(ERRCODE_DIVISION_BY_ZERO),errmsg(“division by zero”))); /* No overflow is possible */ PG_RETURN_INT32((int32) arg1 / arg2);Figure 2: An unexpected optimization voids the division-by-zerocheck, in src/backend/utils/adt/int8.c of PostgreSQL. The call toereport(ERROR, :::) will raise an exception.Essentially, the compiler assumes that ereport will return,
Tom
c# spotify
I need to keep a database up-to-date with a playlist’s contents.I am using the C# Wrapper for the libspotify api – http://libspotify-sharp.hallerud.se/My work flow is as follows at presentLogin, wait for playlist container to load, when loaded listen for playlist loaded events, when the playlist I am interested in is loaded wait for all the tracks on the playlist to have loaded, then write the contents to the db.I am completely clearing the cache directory everytime the program starts. I am find
Daniel
applescript spotify scripting-bridge
I use Scripting Bridge (Cocoa) to access AppleScript methods and properties of Spotify. For example, I need to access artwork of the current playing track. On the most of my machines Spotify pushes an ordinary instance of NSImage class, which I can access via something like [[spotifyApp currentTrack] artwork], and everything works as expected.But on the one of my machines and one friend’s machine-instead of an instance of NSImage class-I get very strange SpotifyImageData by calling still the sam
Duncan Bayne
spotify
I’m building a Raspberry Pi based valve-amplified MP3 player, housed in a restored Westminster radio case:http://www.youtube.com/watch?v=oTabLcVgvwoI’d like to write a simple Free client that starts playing a particular named playlist (‘Westiamp’, which is the name of the project) immediately. It’ll also interface to a USB-connected control panel for skipping between tracks, etc. There will be a simple web UI for entering username and password to log in to Spotify, and WiFi details.My question
quetzalcoatl
spotify libspotify
Currently we’re implementing Libspotify in a win 7 64 bit system. Everything seems to work fine except the playback. We get data from the callback , but even using audicity on the saved audio, is filled with abnormalities. So to research further we took the win32 sample (spshell ) and modified it to save the music data to file. Same problem, definitely music with these ticks in it. I’m sure there’s something simple I’m missing here, but I’m at a loss as to what could be the problem. Any help wo
Kristofer Sommestad
spotify cocoalibspotify-2.0
I’m using cocoalibspotify for a Spotify iOS app.At one point in my app, I’m creating a new playlist and add a number of tracks to the playlist. When doing so, I’m getting a crash since the created playlist instance seem to have been deallocated. This is what the code looks like:[[[SPSession sharedSession] userPlaylists] createPlaylistWithName:playlistName callback:^(SPPlaylist *createdPlaylist) {if (createdPlaylist) {[SPAsyncLoading waitUntilLoaded:createdPlaylist then:^(NSArray *playlists) {//
Tigresstamm
api position player spotify
I’m trying to play a song from a position other than the beginning of the track.I’ve found that player.position = X will work as a standalone function, such as triggered by a button, but triggering it on player.observe(models.EVENT.CHANGE… results in a crash.I figure this is because the track hasn’t actually started playing once the event occurs as the player.position may still be at the previous song’s position.I’ve also experimented with sp.trackPlayer.seek() which seems to give the same res
Laurens
spotify
I’m trying to write a visualizer for Spotify using the Processing library.But I have a problem with the audio.RealtimeAnalyzer class.var analyzer = audio.RealtimeAnalyzer.forPlayer(models.player); analyzer.addEventListener(‘audio’, function(data){ … });If I let this run for an hour Spotify is using more then 1.5GB of memory and eventually crashes. Is there any possibility for dumping or freeing all this unnecessary memory? Or can I solve this issue with using an other class?
user605710
spotify
I’m trying to develop a Spotify app — it uses setInterval to change a canvas element, in order to create some animation.Like two others I found, my app seems to just rampantly eat memory until the app crashes, and it does not take long. Neither of these has answers — Spotify directs us to ask tech-support questions here. Anyone know why this happens or how to fix it? Thanks BobSpotify Apps API Memory Leak Spotify App API memory leak
TiagoOliveira
c spotify libspotify
I was testing out libspotify library (version 12.1.51 x86 for linux) and the application keeps crashing when I call sp_session_create() with a segmentation fault. I don’t have application key, nor a Premium Spotify account (yet), but that shouldn’t be the reason for the crash, since if I remember correctly, there is an error code for invalid application key.My code is as follows:static uint_8_t g_appkey[] = {1, 2, 3}; static const char *username = “MyUsername”; static const char *password = “MyP
Ivan Kelly
c segmentation-fault spotify libspotify
I’m getting a segmentation fault using if I try to call sp_session_logout after playing a song. I can’t really say much about the segfault, as I don’t have the symbols, With the following code the segfault occurs every time after logout is called https://gist.github.com/ivankelly/5564318#0 0x00007ffff7ac5746 in ?? () from /home/ivan/Apps/lib/libspotify.so.12 #1 0x00007ffff7a38289 in ?? () from /home/ivan/Apps/lib/libspotify.so.12 #2 0x00007ffff7a38535 in ?? () from /home/ivan/Apps/lib/libspot
quetzalcoatl
spotify libspotify
Currently we’re implementing Libspotify in a win 7 64 bit system. Everything seems to work fine except the playback. We get data from the callback , but even using audicity on the saved audio, is filled with abnormalities. So to research further we took the win32 sample (spshell ) and modified it to save the music data to file. Same problem, definitely music with these ticks in it. I’m sure there’s something simple I’m missing here, but I’m at a loss as to what could be the problem. Any help wo
TiagoOliveira
c spotify libspotify
I was testing out libspotify library (version 12.1.51 x86 for linux) and the application keeps crashing when I call sp_session_create() with a segmentation fault. I don’t have application key, nor a Premium Spotify account (yet), but that shouldn’t be the reason for the crash, since if I remember correctly, there is an error code for invalid application key.My code is as follows:static uint_8_t g_appkey[] = {1, 2, 3}; static const char *username = “MyUsername”; static const char *password = “MyP
Ivan Kelly
c segmentation-fault spotify libspotify
I’m getting a segmentation fault using if I try to call sp_session_logout after playing a song. I can’t really say much about the segfault, as I don’t have the symbols, With the following code the segfault occurs every time after logout is called https://gist.github.com/ivankelly/5564318#0 0x00007ffff7ac5746 in ?? () from /home/ivan/Apps/lib/libspotify.so.12 #1 0x00007ffff7a38289 in ?? () from /home/ivan/Apps/lib/libspotify.so.12 #2 0x00007ffff7a38535 in ?? () from /home/ivan/Apps/lib/libspot
FrontierPsychiatrist
node.js libspotify
I am trying to write a module for nodeJS which wraps libspotify. The goal is to write a webapp that allows the remote control of a device playing music from spotify.I have decided to go along the spshell example to ensure thread safety and write a “Spotify Service” in plain C that starts a seperate thread which calls all the API functions.The nodeJS module then just calls a few provided functions to interact with spotify. The code for the service can be found here: http://pastebin.com/KB6uwSC8 T
Web site is in building